• Resolved ninja-master-jimmy-wong-fu

    (@ninja-master-jimmy-wong-fu)


    I have a home page with the following code above the loop to show News posts only.

    <?php if (have_posts()) : ?>
    <?php
    $temp = $wp_query;
    $wp_query= null;
    $wp_query = new WP_Query();
    $wp_query->query(‘showposts=10′.’&paged=’.$paged.’&category_name=News’);
    ?>

    I also have wp-post-numbers installed, which is displayed as follows:

    <?php if(function_exists(‘wp_page_numbers’)) { wp_page_numbers(); } ?>

    For some reason the wp-page numbers cannot display the page numbers properly. For example, if I set it to display 10 posts per page and I have 18 posts in total I would expect it to show only two page numbers (one for each page – ten on the first; eight on the next). Instead It shows three, and if you click on the third one it displays an error (no posts found).

    Any ideas or workaround?

Viewing 2 replies - 1 through 2 (of 2 total)
  • Moderator keesiemeijer

    (@keesiemeijer)

    try this:

    <?php if (have_posts()) : ?>
    <?php
    $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
    $temp = $wp_query;
    $wp_query= null;
    $wp_query = new WP_Query();
    $wp_query->query('showposts=10'.'&paged='.$paged.'&category_name=News');
    ?>

    Thread Starter ninja-master-jimmy-wong-fu

    (@ninja-master-jimmy-wong-fu)

    As long as the above code is placed above the wp-page-nembers code it works perfectly!!

    For example:

    <?php if (have_posts()) : ?>
    <?php
    $paged = (get_query_var(‘paged’)) ? get_query_var(‘paged’) : 1;
    $temp = $wp_query;
    $wp_query= null;
    $wp_query = new WP_Query();
    $wp_query->query(‘showposts=10′.’&paged=’.$paged.’&category_name=News’);
    ?>

    <?php if(function_exists(‘wp_page_numbers’)) { wp_page_numbers(); } ?>

    Then add the loop

    Thanks a million for your quick response!!!!!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘wp-page-numbers incorrectly displaying on news only home page’ is closed to new replies.