Lista de categoria com o último post de cada categoria no WordPress


Postado em 13 de maio de 2011 por | Categorias: Categorias | Tags: | 1 Comentário » | Comentar


Para montar uma lista de categorias exibindo o resumo do último post de cada categoria use o código abaixo.

<?php
 $categories= get_categories();

$ic=1;
foreach ($categories as $category) {

 $category = $category->cat_ID;
 query_posts("showposts=1&cat=$category"); ?>

<?php while (have_posts()): the_post(); ?>
<div style="margin-right: 12px;">

 <h4><a href="<?php echo get_category_link($category);?>"><?php single_cat_title(); ?> &raquo;</a></h4>
 <div></div>

 <?php get_the_image( array( 'custom_key' => array( 'thumbnail' ), 'default_size' => 'thumbnail', 'width' => '140', 'height' => '140' ) ); ?>
 <h6><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title() ?></a></h6>
 <p style="color:#838383;"><?php the_time('d M, Y') ?></p>
 <p><?php echo substr(get_the_excerpt(),0,100)."(...)"; ?></p>

</div>

<?php //echo $ic; ?>
<?php $ic=$ic+1; endwhile; ?>
<?php } ?>

 

Referência do comando get_categories(): http://codex.wordpress.org/Function_Reference/get_categories

Share

Categorias

Links

Tags

Autor do post bloginfo() Caminho do tema Campos Personalizados Categorias Codificação UTF8 Contac form 7 CSS Custom fields Custom Post Types data Dividir string explode() Formatação de datas Formatação de Hora get_ get_option() get_page_template() get_the_terms get_the_title() Hora IMG is_single() Janelas Links Lista de Categorias Lista de Posts Lista de ùltimos posts location.href Paginação Post_name Query_posts register_sidebar Sidebar the_author_nickname() the_category() the_tags() the_time() Titulo da página UFT8_encode UTF8 UTF8_decode Widgets wp_list_categories() âncoras

Copyright © 2024  |   W-Pedia – Wikipedia Wordpress BR  |  produzido por Henderson C. Torres