Support » Fixing WordPress » how to exclude featured category from previous posts?

  • Resolved Skeary


    I used the guide on the codex page about the loop to extract the most recent post of a featured category to be at the top of my page.

    But now I’m realizing that when I click ‘older posts’ on the bottom of my page, the archives still show this post at the top. I have no idea how to do this.. but I feel that it shouldn’t be toooo hard..

    The code I used was based off this (from the codex)

    <?php $my_query = new WP_Query('category_name=featured&showposts=1');
      while ($my_query->have_posts()) : $my_query->the_post();
      $do_not_duplicate = $post->ID;?>
        <!-- Do stuff... -->
      <?php endwhile; ?>
        <!-- Do other stuff... -->
      <?php if (have_posts()) : while (have_posts()) : the_post();
      if( $post->ID == $do_not_duplicate ) continue; update_post_caches($posts); ?>
       <!-- Do stuff... -->
      <?php endwhile; endif; ?>
Viewing 4 replies - 1 through 4 (of 4 total)
  • Change:

    while ($my_query->have_posts()) :


    while (is_home() && !is_paged() && $my_query->have_posts()) :

    excellent.. that definitely MOSTLY does what I need.. thanks so much.
    However it seems to be interacting with something in an odd way… I would guess it is not picking up on all of the stylesheet/formatting, as the margins of the second page are mussed up.
    any idea what I might do to make it right?
    compared to

    on the paged page your content is in a few subdivs, and in #content then a div then #content again, which has a left margin of 280px, which is pushing things over, cause it is doing it twice…if that makes sense!

    So basically you need to look at your html structure if you are on a paged page.

    ahh k.. i moved the <div id=”currentcontent”> behind the ‘while (is_home() && !is_paged() && $my_query->have_posts()) :’ which seems to work as I imagine it makes it not open it unless it is_home
    thanks for the advice! 🙂

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘how to exclude featured category from previous posts?’ is closed to new replies.