I’ve been toying around with this, and i’ve found the problem here, is that whenever you set an array or any category for display you immediately lose the priority of the sticky post…
I’ve tried, category__in, cat, category__and… and every which way i could think of..
Everytime you include posts with stickies AND set the category, stickies seem to lose their order…
However you can retain sticky priority using a pre_get_posts filter like so…
In your functions.php (for your theme), plonk this in…
function setcat_pre_posts($query) {
if ($query->is_home) // Assuming you want this to apply when it's your home page
{
$query->set('cat', '87,88');
}
return $query;
}
add_filter('pre_get_posts', 'setcat_pre_posts');
Change 87, and 88 to your 2 cat IDs, and remove the code you posted above from your index.php
NOTE: Regardless of what category the sticky post is in, it should still show up (it did in my testing), and in the correct place(the top).
If stickies don’t show up then add the query_posts line into the index.php with the caller_get_posts parameter like so, you should then see posts from the 2 categories and the sticky (but at the top).
query_posts('caller_get_posts=0')
If you wanted to only apply the filter when stickies exist, then you could change the function to..
function setcat_pre_posts($query) {
$testst = get_option('sticky_posts');
if($testst[0]) { // If there's first item, then we have stickies
if ($query->is_home) {
$query->set('cat', '87,88');
}
}
return $query;
}
add_filter('pre_get_posts', 'setcat_pre_posts');
I don’t know why this method works exactly, but it does… you get stickies at the top (regardless of category), then posts that follow filtered by the 2 assigned ID’s above… ??