WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] how to exclude featured category from previous posts? (5 posts)

  1. Skeary
    Member
    Posted 6 years ago #

    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; ?>
  2. Kafkaesqui

    Posted 6 years ago #

    Change:

    while ($my_query->have_posts()) :

    to:

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

  3. Skeary
    Member
    Posted 6 years ago #

    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?
    http://www.radioslipstream.com/wp/index.php?paged=2
    compared to
    http://www.radioslipstream.com/wp/
    hrum..

  4. Alex Cragg
    Member
    Posted 6 years ago #

    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.

  5. Skeary
    Member
    Posted 6 years ago #

    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! :)

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.