Você está na página 1de 4

Cdigosdowordpress

Cdigosiniciais
Header
Insereantesdefecharohead.Casodalgumaquebradescript,podereposicionar.O
idealantesdefechar.
<?phpwp_head();?>
Footer
Colocaantesdefecharobody,depoisdaltimadiv(ouelementoquefor).
<?phpwp_footer();?>
Pegarolinkdapastatema
<?phpbloginfo('template_directory');?>
Pegarolinkdoblog
<?phpbloginfo(blog_url);?>
Menu
<?php
wp_nav_menu(
array(
'menu'=>'navegacaoprincipal',
'container'=>'false',
'menu_class'=>'sfmenu'
)
);
?>
<?php
wp_nav_menu(
array(
'theme_location'=>'sidebarmenino',
'container'=>'false'
)
);
?>
Functions
//SuporteaCustomMenus
if(function_exists('register_nav_menu')){
register_nav_menus(array(
'navegacaoprincipal'=>__('NavegacaoPrincipal','footer'),
'sidebarmenino'=>__('SidebarMenino','footer'),
));
//Makethemeavailablefortranslation
//Translationscanbefiledinthe/languages/directory
load_theme_textdomain('footer');
}
Informaesparaapgina
Ttulo
<?phpif(have_posts()):while(have_posts()):the_post();?>
<?phpthe_title();?>
<?phpendwhile;endif;?>

Resumo
<?phpthe_excerpt();?>
Contedo
<?phpthe_content();?>
Link
<?phpthe_permalink();?>
Adicionarresumo
Primeironofunctions.php

adicionar:
/************************************************
LIMITARNMERODEPALAVRASNOSEXCERPTS
*************************************************/
functionlimit_words($string,$word_limit)
{
$words=explode('',$string,($word_limit+1));
if(count($words)>$word_limit){array_pop($words);
array_push($words,"...");}
returnimplode('',$words);
}
Cdigo:
<?phpecholimit_words(get_the_content(),'5');?>
Link
<?phpthe_permalink();?>
Imagemdestacada
<?phpif(has_post_thumbnail()){the_post_thumbnail(array(575,187));}?>
Adicionarcdigosdeplugins(comoContactForm)
<?phpechodo_shortcode();?>
Category
Ttulo
<?php
$category=get_the_category();
echo$category[0]>cat_name;
?>
Repetio
<?phpif(have_posts()):while(have_posts()):the_post();?>
Cdigo
<?phpendwhile;endif;?>
Dataeautor
<?php

while(have_posts()) : the_post();
global $post;

$data = date("Y-m-d H:i:s"); //Define a data atual


if($post->post_date >= $data) //verifica se a data do post
maior ou igual a data atual. o resto do codigo eh de praxi pra
colocar na tela
{
?>
<div class="noticias_lineposts">
<p><?php the_time('l, j \d\e F \d\e Y'); ?> s <?
php the_time('G\hi'); ?></p>
<h3><a href="<?php echo the_permalink();?>"
rel="bookmark" title="<?php the_title_attribute(); ?>"><?php echo
get_the_title(); ?></a></h3>
</div>
<?php
}
endwhile; //fim while
?>

Chamar posts de uma category em outra pgina


<?php
$args=array('numberposts'=>1,'order'=>'DESC','orderby'=>'date','cat'=>'1');
$postslist=get_posts($args);
foreach($postslistas$post):setup_postdata($post);
?>
Informaes
<?phpendforeach;?>
AtivaroRSS
<?phpbloginfo('rdf_url');?>
OptionTree
<?php
for($i=1;$i<4+1;$i++){
$image=get_option_tree("slide_img{$i}");
$title=get_option_tree("slide_title{$i}");
$text=get_option_tree("slide_text{$i}");
$link=get_option_tree("slide_link{$i}");

if(empty($image)&&empty($title)){
continue;
}
else{
if(empty($title)){?>
<divid="slide1">
<div>
<ahref="<?phpecho$link;?>"><imgsrc="<?phpecho$image;?>"
alt="<?phpecho$title;?>"/></a>
</div>
</div><!.slide1>
<?php
}

else{?>
<divid="slide1"><ahref="<?phpecho
$link;?>">

<div>

$image;?>"alt="<?phpecho$title;?>"/>

<imgsrc="<?phpecho
</div>
<divclass="description">
<div>
<h2><?phpecho

$title;?></h2>

</div>
<div>

?></p>

<p><?phpecho$text;

</div>
</div>
</a></div><!.slide1>
<?php
}
}

}
?>
<?php$image=get_option_tree("slideshow_img");?>
Pginascustomizadas(template)
<?php
/*
TemplateName:Pginadecontato
*/
?>
Alternarentreumphpeoutrodependendodacategory
<?php
$post=$wp_query>post;
if(in_category('news')){
include(TEMPLATEPATH.'/categorynews.php');
}
else{
include(TEMPLATEPATH.'/categoryportfolio.php');
}
?>

Você também pode gostar