• mckaymultimedia

    (@mckaymultimedia)


    I have created a popular post page template for a theme that is under development. I plan to sort the posts by popularity based on page views. I have the page view tracking setup in custom fields for the posts and I even have a query string that retrieves the most popular posts in order successfully. On the first actual popular posts page it displays as it should.

    The problem I am having is that when you click to view the next page of popular posts using the pagination, it displays the same popular posts from the first page. Example: page “domain.com/popular” shows the top five popular posts, page “domain.com/popular/page/2” shows the same top five popular posts as the first page, and so on. The query isn’t recognizing the pagination.

    I am no PHP or database expert so I am at a loss for what is going wrong here. My last resort will be to limit the popular posts page to a set number of posts, removing pagination. Here is the query in place before the loop…

    <? query_posts('meta_key=post_views_count&orderby=meta_value_num&order=DESC&posts_per_page=5'); ?><?php if (have_posts()) : while (have_posts()) : the_post(); ?>

    Any help, suggestions, or insight from more knowledgeable coders would be greatly appreciated.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter mckaymultimedia

    (@mckaymultimedia)

    Bumpsky.

    Hello mckaymultimedia, I have the same problem. You found any solution?

    Thank you in advance.

    Thread Starter mckaymultimedia

    (@mckaymultimedia)

    In fact I did. I ended up figuring out a working query string on my own. Here is what worked for me.

    <?php query_posts(array('posts_per_page' => 5, 'meta_key' => 'post_views_count', 'orderby' => 'meta_value_num', 'order' => 'DESC', 'ignore_sticky_posts' => 'true', 'paged' => ( get_query_var('paged') ? get_query_var('paged') : 1 ), )); ?>

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Popular Post Page Template Query Post Pagination Problem’ is closed to new replies.