WordPress.org

Support

Support » How-To and Troubleshooting » [Resolved] can a single post in a category be excluded from the loop

[Resolved] can a single post in a category be excluded from the loop

  • Can anything be added to this code

    <?php if (in_category('3')) : ?>
    <p class="date">POSTED <?php the_time('F d, Y') ?></p>
    <?php endif; ?>

    that will say “if in category 3 EXCEPT for post 50, show this”

    I tried
    <?php if (in_category('3&exclude=50')) : ?> and (in_category('3&exclude=p50'))
    but that deletes the code on all the posts

Viewing 1 replies (of 1 total)
  • This title is the wrong question. The answer to the TITLE is: yes. to exclude a post just use this:
    <?php if (have_posts()) : while (have_posts()) : the_post(); if( $post->ID == '179' ) continue; ?>

    Here, post ID 179 will not be included in the listing.

    Will ask the correct question in another post.

Viewing 1 replies (of 1 total)
  • The topic ‘[Resolved] can a single post in a category be excluded from the loop’ is closed to new replies.
Skip to toolbar