X

La manera fácil de mostrar entradas recientes en WordPress

No es necesario realizar consultas personalizadas o llamadas a bases de datos para obtener una lista de entradas recientes. De hecho, hay una función integrada en WordPress que hará precisamente eso. Se llama, wp_get_archives(). Puede que la reconozca como una forma de mostrar los archivos mensuales, pero con unos pocos parámetros, puede modificarla para mostrar una lista de entradas de WordPress publicadas recientemente. Aquí está el código:

<?php wp_get_archives('title_li=&type=postbypost&limit=10'); ?>

Esto eliminará cualquier formato añadido por WordPress y mostrará una lista de las 10 últimas entradas, cada una dentro de su propia etiqueta <li>.

Comentarios   Deja una respuesta

  1. Ellery Davies mayo 24, 2013 en 8:52 am

    I use the WordPress Twenty-Eleven theme and have always displayed recent posts using the widget in Jetpack. But I want this list to show in the individual posts as well. Is there a way to do this?

  2. Muchas gracias!!!! Thank you very much!!!! Just what I was looking for!

    Saludos desde Spain 😉
    Sara

  3. Thanks! That solved my problem in 2 seconds.

  4. Thanx Leland – just in the nick of time
    *Love ur site btw 😀

    M.?

  5. Sachin @ Web Design Mauritius mayo 14, 2010 en 8:30 am

    I’ve implemented it on my about page here: http://www.webdesign-bureau-of-mauritius.com/web-design-mauritius

    It works like a charm. Thanks for this!

  6. Can you also tell the system to display the excerpt for the post? or just a teaser?

  7. Okay. All this code does is display a very simple list of recent posts. The markup is similar to this:

    <ul>
    <li><a href="http://example.com/recent-post-3">Latest One</a></li>
    <li><a href="http://example.com/recent-post-2">2nd Latest Post</a></li>
    <li><a href="http://example.com/recent-post-1">3rd Latest Post</a></li>
    </ul>

    If you want anything else (thumbnails, character counts, whatever) that would require a custom loop and I can’t really go over each specific case in the comments here.

  8. How do I do this and also have thumbnails? Very small thumbnails. 35px X 35 px. Google is annoying me sending me round in circles all day long. They’re useless lol.

    Well I await your useful reply.

    Thanks.

    1. Oh wow this is easy 😀 Thanks for this great article!

      BTW, has anyone come across functions to merge both recent post and page update in chronological order?

Añadir un comentario Cancelar respuesta

Nos alegra que haya decidido dejar un comentario. Tenga en cuenta que todos los comentarios se moderan de acuerdo con nuestra política de privacidad , y que todos los enlaces son nofollow. NO utilice palabras clave en el campo del nombre. Tengamos una conversación personal y significativa.

WordPress Launch Checklist

La lista definitiva para lanzar WordPress

Hemos recopilado todos los elementos esenciales de la lista de comprobación para el lanzamiento de su próximo sitio web de WordPress en un práctico ebook.
Sí, envíeme el ¡gratuito!