WordPress Code only showing 1 post

I am using this code:

<?php
    query_posts( 'posts_per_page=5' );


    while ( have_posts() ) : the_post();
       echo '<li>';
         the_title();
       echo '</li>';
    endwhile;

    wp_reset_query();
?>

The code works but there are 2 posts and it’s only returning the latest one.

Read More

I need it to show them all.

Can anyone help please?

Thanks

Related posts

Leave a Reply

1 comment

  1. Try this:

     $query = new WP_Query('posts_per_page=5');
    
     while( $query ->have_posts() ) : $query ->the_post();
         echo '<li>';
         the_title();
         echo '</li>';
     endwhile;
    
     wp_reset_postdata();