Add a second WordPress Loop that displays latest posts in single.php

I am creating my own Theme, but have only basic knowledge of PHP. I’ve been looking for a way to do this online but cannot seem to come across it.

This is the url of my development server: http://dev.mindthegaspar.com/nuevanacion/

Read More

I want to have a secondary loop in every page on the sidebar that displays all the latests posts. It is straightforward on the main Index.php file.

I’m not sure where yo begin to get it working on the Single.php file. I understand he concept of the WordPress loop, and why it won’t work inside a Category of Post page, but is there a way around this?

Thanks

Related posts

Leave a Reply

1 comment

  1. add this to your sidebar:

    $today = getdate();
    $sidebarquery = new WP_Query( 'year=' . $today["year"] . '&monthnum=' . $today["mon"] . '&day=' . $today["mday"] );
    
    while($sidebarquery->have_posts()) {
       $sidebarquery->the_post();
       echo '<li>' .  the_permalink(); . '</li>';
    }