What’s a better alternative to this code?

Having read ‘don’t use query_posts’, I’ve also read that it’s ok to use ‘for displaying a list of posts or custom-post-type posts on a page (using a page template), and you want to make pagination of those posts work’.

So, in wanting to use it for exactly that, my code is:

$page = (get_query_var('paged')) ? get_query_var('paged') : 1;
while (have_posts()) : the_post();

<p><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></p>
<?php endwhile ?>

Not being smart enough to know, I’m wondering if there’s a better alternative.

Read more here: What’s a better alternative to this code?

Leave a Reply

Your email address will not be published. Required fields are marked *