WordPress.org

Ready to get started?Download WordPress

Forums

posts_nav_link and excluded articles (3 posts)

  1. ivansuchy
    Member
    Posted 8 years ago #

    Hello, guys / girls?

    I'm hidding some articles from view in LOOP via following code:
    --

    <?php if (have_posts()): ?>
    <?php while (have_posts()) : the_post(); ?>
    <? if(!in_category(500)): ?> //show article

    --
    but post_nav_link() function counts all posts so there is a problem, when I have 11 posts in database and 10 per page setting, I see link to "older articles" but 11th article is not visible of course so page no. 2 is empty.
    --

  2. Use query_posts().

    Just use it right above the <?php if (have_posts()): ?>.

  3. ivansuchy
    Member
    Posted 8 years ago #

    Thanks Viper, but solution looks like the following:

    <?php $wp_query->set( 'cat', '-500' ); ?>
    <?php query_posts( '' ); ?>

Topic Closed

This topic has been closed to new replies.

About this Topic