WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Only display sticky posts on 2.7 homepage (5 posts)

  1. tshirtfiend
    Member
    Posted 5 years ago #

    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?

  2. Austin Matzko
    Member
    Posted 5 years ago #

    You want to use the is_sticky conditional template tag.

  3. sleeplessinDC
    Member
    Posted 5 years ago #

    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.

  4. tshirtfiend
    Member
    Posted 5 years ago #

    @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.

  5. tshirtfiend
    Member
    Posted 5 years ago #

    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…

Topic Closed

This topic has been closed to new replies.

About this Topic