Como mostrar post aleatorios en el sidebar
Posted on Sábado, Julio 18, 2009 in Wordpress
Ultimamente he pensado que tenía artículos desaprovechados en mi blog.Y que la solución a esto era buscar una forma de mostrar Post aleatorios en nuestro Sidebar que cambiaran aleatoriamente .
Leyendo por la web he encontrado un código que se añade por un widget de texto y un plugin que es el que utilizamos en nuestro blog y es verdaderamente efectivo y eficaz.
El código que deberiamos introducir si lo quisieramos hacer manualmente sería este.
<?php
query_posts(array('orderby' => 'rand', 'showposts' => 1));
if (have_posts()) :
while (have_posts()) : the_post();
the_title();
the_excerpt();
endwhile;
endif;
?>
Y también podemos descarganos el plugin Random Post widget de fácil instalación.
Opciones del Plugin:
Widget title: the title of the widget- List types: ul for bulleted list, p for paragraph, br for paragraph with line breaks
- Before title and After title: you have to find out what your theme uses before and after the
widget headers. A simple way to do this is to identify a currently existing widget in your site and viewing the source. Find the title and see what is printed before and after. For example it might show as <h2> Widget Title</h2> which is used by most themes. - Post count: Number of random posts you would like to be displayed
Basically that’s it. It’s really
a simple widget. Si te ha gustado este post, porfavor suscribete a mi RSS feed!

Leave a Comment