WordPress.org

Support

Support » How-To and Troubleshooting » [Resolved] Disabling pagenumbers/pagination with WP_Query

[Resolved] Disabling pagenumbers/pagination with WP_Query

  • Hi,

    I’m trying to stop the pagenumbers from showing when using WP_Query to show posts from a category. I only want to show the 3 most recent posts and don’t want the option to go to any other page.
    I’m using the following code:

    <?php
    $wp_query = new WP_Query();
    $wp_query->query('category_name=NEWSITEMS&showposts=3');
    ?>
    <?php while ($wp_query->have_posts()) : $wp_query->the_post(); ?>
     <li><a href="<?php the_permalink(); ?>">
              <?php the_title(); ?>
              </a>  </li>
    <?php endwhile; ?>

    I’ve tried different parameters like is_paged and paged, but that doesn’t seem to do what I’m trying to achieve.
    Any help would be greatly appreciated!

    LaDoza

Viewing 5 replies - 1 through 5 (of 5 total)
  • Well the option to go to another page really isn’t provided by query_posts, but some other thing like template tag, previous_posts_link() and next_posts_link(), or a plugin such as wp-pagenavi.

    Thanks for your reply.
    But I don’t understand, why does a pagenumber show up when I use the posted code? I am not using any navigation plugins and I’m not calling any navigational functions.

    Deactivate plugins and change to the WordPress Default theme to see if the problem persists.

    There indeed are no pagenumbers when the default theme is activated. Hmm must really be something template-related then, I’ll go try and find it. Thanks for pointing me in the right direction!

    [Edit] It’s weird though, I made my template from scratch and don’t recall building in any pagination functions. I hope I’ll find what is causing it (plugins are deactivated).

    Found it!

    I used the above code in a file called news.php and included that on my postpage using echo include (TEMPLATEPATH . '/news.php');

    I changed that to include (TEMPLATEPATH . '/news.php'); (dropped the echo) and now the number’s gone. Had nothing to do with the wp_query function at all 🙂

    Thanks for your replies

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘[Resolved] Disabling pagenumbers/pagination with WP_Query’ is closed to new replies.