Forums

Show sticky posts above other posts in query_posts (2 posts)

  1. greencode
    Member
    Posted 11 months ago #

    I'm a bit stuck! I'm trying to show sticky posts before a load of other posts on my homepage. I've been using this code:

    $sticky = get_option( 'sticky_posts' );
    query_posts('$sticky&cat=5&posts_per_page=5&orderby=rand&order=DESC');

    But it doesn't work!

    Any ideas or help would be greatly appreciated.

  2. vtxyzzy
    Member
    Posted 11 months ago #

    I think you have a couple of problems.

    First, $sticky will only contain a comma separated list of post IDs, so it cannot be used in the query as you have it coded.

    Second, I believe (but not 100% sure) that the orderby=rand will override the use of sticky posts.

    You probably will need to have two separate loops to accomplish what you want.

Reply

You must log in to post.

About this Topic