Forums

Show just one sticky post on a page (2 posts)

  1. jitpal
    Member
    Posted 3 years ago #

    I've looked all over but I can't seem to find the info I was looking for. My goal is to have a page be the index. On that I want static text(not a problem), custom sidebar(also not a problem) and then below the static text, I want to show the most current sticky post. I'm somewhat confused as to how to accomplish this. I think I would have to create a page template, add the loop, then tell the loop to only return sticky posts and limit it to one.

    Only problem is, I have no idea how to actually add the loop and tell it to return only sticky posts. I looked through the Codex, but I couldn't really find it. Am I on the right track? Is there are better/easier way to do what I want to do?

    Thanks, I greatly appreciate your help.

  2. buddha trance
    Member
    Posted 3 years ago #

    http://codex.wordpress.org/Template_Tags/query_posts#Sticky_Post_Parameters

    I think it would work if you add to the template
    <?php $sticky=get_option('sticky_posts') ; ?>

    To return just the first sticky post

    <?php $sticky=get_option('sticky_posts') ;
    query_posts('p=' . $sticky[0]);
     ?>

    Try by making a template out of a copy of index.php, and inserting the query. Then, you can add the static text into the template.

    Or create a simple page template, and just add the query into it, see if it works that way.

Topic Closed

This topic has been closed to new replies.

About this Topic