Utilizando la función query_posts() listaremos en el sidebar los últimos post que hemos creado, mostrando además un segundo ejemplo en el caso que queramos enseñar los últimos post de una categoría determinada.
Código para listar las últimas entradas:
1
2
3
4
5
6
7
8
9
10
|
<div class=“ultimas-entradas”>
<?php query_posts(‘showposts=5’);?>
<?php if (have_posts()) : while (have_posts()) : the_post();?>
<ul>
<li>
<h2><a href=“<?php the_permalink();?> title=”<?php the_title_attribute();?>“><?php the_title();?></a></h2>
</li>
<ul>
<?php endwhile; endif;?>
</div>
|
La función: (‘showposts=5′) nos indica cuantos posts se van a mostrar, si queremos que nos muestre más que 5, lo que deberemos hacer es cambiarlo por el que queramos.
Código para listar las últimas entradas de determinada categoría:
1
2
3
4
5
6
7
8
9
10
|
<div class=“ultimas-entradas”>
<?php query_posts(‘category_name=photoshop&showposts=5’);?>
<?php if (have_posts()) : while (have_posts()) : the_post();?>
<ul>
<li>
<h2><a href=“<?php the_permalink();?> title=”<?php the_title_attribute();?>“><?php the_title();?></a></h2>
</li>
<ul>
<?php endwhile; endif;?>
</div>
|
Donde dice photoshop en (‘category_name’) deberemos suplantarlo por el nombre de la sección que queremos listar.