I am using this code to get IDs of posts which are in a ‘featured’ category. But can I retrieve those posts as well which are also sticky, using the same query?
$post_ids = get_posts(array(
'numberposts' => 8,
'category_name' => 'featured',
'orderby' => 'date',
'post_type' => 'post',
'fields' => 'ids'
));
Right now I am using two queries to get the desired results, but I think there is a better way to do this:
//get featured ids
$post_ids = get_posts(array(
'numberposts' => 5,
'category_name' => 'featured',
'orderby' => 'date',
'post_type' => 'post',
'fields' => 'ids'
));
//get sticky id
$sticky_post_ids = get_posts(array(
'numberposts' => '1',
'orderby' => 'date',
'post_type' => 'post',
'fields' => 'ids'
'post__in' => get_option('sticky_posts')
));