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;
query_posts("&post_type=host&showposts=10&orderby=name&order=asc&paged=$page");
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?


Solution:

If you know the solution of this issue, please leave us a reply in Comment section, to update the question.


Wordpress related questions and answers: