Topic: Option to ignore 'sticky' in $news_query

There are 2 ways of using featured posts in WordPress,

the old way with a featured category, or the new 2.7 way with sticky posts.
Arras is one of the little theme who use the sticky feature, many themes only use the featured category.

But Arras could be a bit improved on the sticky part.

On the homepage, you could using stickies for the featured slider/content.
The result has effect on the next part 'News',
it will show this:
first: all sticky posts
next: the latest post, limited by the number you've entered.

So when you've set to display the 12 latest posts, and you have 4 stickies, it will display 16 posts.

This also affects the featured posts widget.

How to solve?
I've fixed it this way, but there might be a better way.

home.php line 61:

$news_query_args = array(
[b]    'caller_get_posts' => 1,[/b]
    'cat' => $news_cat,
    'paged' => $paged,
    'showposts' => ( (arras_get_option('index_count') == 0 ? get_option('posts_per_page') : arras_get_option('index_count')) )
);

The 'caller_get_posts' => 1 excludes stickies in the loop, which seems logical, since they're allready displayed in the featured slider/content part.


For the featured posts widget currently i haven't got the perfect sollution, for personal use i've added 'caller_get_posts' => 1 in line 231 library/widgets

$r = new WP_Query( array('caller_get_posts' => 1, 'showposts' => $instance['postcount'], 'cat' => $cat) );

But an option to choose between sticky on the list of categories would be a handy addition.

Last edited by freakenstein (2010-12-20 18:15:15)

Converting to 1.5 with childtheme
De Nachtvlinders: horror

Re: Option to ignore 'sticky' in $news_query

Hmm, this worked for 1.4,
but i'm converting to 1.5 with childtheme,

does anyone have an idea how the achieve this?

Seems in 3.1 something will change aswell:
http://codex.wordpress.org/Function_Ref … Parameters

ignore_sticky_posts=1 - To ignore (or exclude) sticky posts being included at the beginning of posts returned, but the sticky post will still be returned in the natural order of that list of posts returned. Note this parameter was introduced with Version 3.1 and replaced the deprecated caller_get_post.

Converting to 1.5 with childtheme
De Nachtvlinders: horror

Re: Option to ignore 'sticky' in $news_query

For Arras 1.5

Some logical thinking and some trial and error,
the solution was easy.

in home.php line 61:
after

$news_query['paged'] = $paged;

add for WordPress 3.0:

$news_query = array('caller_get_posts' => 1);

or for WordPress 3.1:

$news_query = array('ignore_sticky_posts' => 1);

This is offcourse an hack,
I'm currently looking for a solution to add this option into the childtheme's functions.php

For those who are reading and think 'what's this all about'?
This function let's WordPress ignore the sticky status and returns all posts in their natural datebased order.
see wordpress codex: http://codex.wordpress.org/Function_Ref … Parameters

Converting to 1.5 with childtheme
De Nachtvlinders: horror

Re: Option to ignore 'sticky' in $news_query

I tried this in the new wp  cool

$news_query = array('ignore_sticky_posts' => 1);

but I get an error....  sad .. any suggestion??
thanks a lot

Thumbs up