I have a page I'm setting up with various sections to display posts. I want the majority of the page to be user-editable, so I'm filling the sections using a shortcode I wrote. Example:
This:
[diversecity section="sounds-flavors" ids=""]
becomes this:
$qs = new WP_Query(
array(
'posts_per_page' => 3,
'category_name' => 'sounds-flavors'
)
);
and returns 3 posts from the "Sounds & Flavors" category.
However, the users want to be able to highlight certain articles in each section, so I added the ids
variable in the shortcode. The idea is that users can put in a comma-separated list of IDs, and that those posts will be prepended to the category list.
This:
[diversecity section="sounds-flavors" ids="12345,12678"]
becomes this:
$qs = new WP_Query(
array(
'posts_per_page' => 3,
'category_name' => 'sounds-flavors',
'post__in' => array(12345,12678)
)
);
but only returns the two posts specified. The desired output is this:
<article id="12345">{First ID Specified}</article>
<article id="12678">{Second ID Specified}</article>
<article id="12980">{Most Recent Post from the Sounds & Flavors category}</article>
I know I can do two queries (one for the specified posts, and for any category posts to fill the remainder, but is it possible to do it in one using WP_Query?
I'm essentially trying to mimic the behavior of sticky posts, so it should technically be possible. Any ideas?