Forum Replies Created

Viewing 4 replies - 1 through 4 (of 4 total)
  • The other concern is that the twin custom loops approach to stickies doesn’t seem to respond to the posts_per_page parameter, eg.

    ‘$news_posts = get_posts(

    array(‘posts_per_page’ => 1,
    ‘post__in’ => get_option(‘sticky_posts’),
    ‘order’ => ‘ASC’,
    ‘cat’ => 6)
    );’

    displays 2 stickies. Using the deprecated showposts works as expected.

    vtxyzzy, thanks for taking the time to respond to this thread.

    When you use a category query, is_archive() returns true and is_home() returns false. Sticky posts are only honored when is_home() is true.

    I have a posts page where the stickies work correctly out of a standard wordpress loop. However, the template sets is_archive and is_home as follows:

    `$wp_query->is_archive = true;
    $wp_query->is_home = false;`

    For my original sticky post/custom loop problem with get_posts, in line with vtxyzzy’s original suggestion, I have resorted to using two custom loops – one for stickies and one for the remaining category posts – and use posts__in and posts__not_in to include or filter out the stickies respectively.

    Though it still bugs me that I can’t get the stickies to work as documented!

    Forum: Fixing WordPress
    In reply to: Please help
    Thread Starter michalien

    (@michalien)

    I’m using a custom loop with get_posts(). Stripping out the category parameter and using a bare get_posts() call still doesn’t put the sticky post at the top.

    This original topic thread was for a custom loop using query_posts() – according to the Codex both are supposed to work with the same parameters for WP2.6+

    get_posts parameters

    query_posts parameters

    I have the same problem with sticky posts in 2.9.2 – but using get_posts() for the custom loop.

Viewing 4 replies - 1 through 4 (of 4 total)