Support » Fixing WordPress » Only display sticky posts on 2.7 homepage

  • Resolved tshirtfiend


    Is there a way to only show the posts that I’ve marked as sticky on my homepage?

    Setting the # of posts just adds to the number of sticky posts, as some people have pointed out (eg. 5 posts + 5 sticky posts = 10 posts). At the same time, however, I can’t choose to display 0 posts.

    Anybody have a solution?

Viewing 4 replies - 1 through 4 (of 4 total)
  • You want to use the is_sticky conditional template tag.

    The answer is well hidden. You can set sticky posts using the Publish box in the right column. Click on “Visibility” Edit. That will open a dropdown menu with a checkbox to stick the post to the homepage.

    @filosofo: Thanks for the reply. For some reason, I didn’t see it sooner.

    I’m not sure how to use the conditional template tag in this situation, however. Should I use the conditional tag instead of the loop (in my index.php file), or is there a way to use it with the loop? I tried a couple things, but to no avail.

    @sleeplessindc: Appreciate the thought, but I got the sticky thing figured out. I’m looking to display ONLY sticky posts on my homepage.

    Ok, think I figured it out. Found another forum post that suggested this:

    <?php query_posts(array('post__in'=>get_option('sticky_posts'))); ?>

    And it seems to be doing what I need it to. I put that on the line before my loop.

    I just have to figure out how to order the sticky posts now…

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Only display sticky posts on 2.7 homepage’ is closed to new replies.