• I’m using wp_query to do the wordpress loop as follows:

    $pagePosts = new WP_Query();
    $pagePosts->query('showposts=10&orderby=date&order=DESC');

    I have marked some posts as sticky, and while they show up as being sticky in the back end, I can’t work out how to tell they are sticky within the loop, and cannot see this info in the raw posts array variable either.

    I’ve tried using is_sticky() and post_class() and they don’t recognise the sticky posts.

    I hope I’m doing something stupid, and hopefully a kind wise owl can shed some light? 🙂

    Thanks for your time.

Viewing 3 replies - 1 through 3 (of 3 total)
  • is_sticky() needs to be used in the loop.

    See Nathan’s article for more info:
    http://www.nathanrice.net/blog/definitive-sticky-posts-guide-for-wordpress-27/

    Thread Starter tidywebdev

    (@tidywebdev)

    Hi Michael,

    Thanks for replying. I am using a loop, just with my WP_Query custom query as the basis of it. Any other data I’ve got at in the standard loop before has also worked for me in the custom loop. I can understand if is_sticky() won’t work in a custom loop, but surely there should be some way of determining whether a post is sticky in it but I can’t seem to see the sticky info being returned??

    Thread Starter tidywebdev

    (@tidywebdev)

    This same code that failed with an older version of WordPress started working with 2.9.1. So I guess it was just some sort of quirk/bug with an older version which has now been resolved. 🙂

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘can’t determine which posts are sticky using wp_query’ is closed to new replies.