It should just be:
$authorPosts = get_posts(
array(
'post_type' => 'post',
'posts_per_page' => -1,
include' => array( 9048, 6289 ),
'meta_query' => array(
array(
'key' => 'author',
'value' => '"' . get_the_ID() . '"',
'compare' => 'LIKE'
)
)
)
);
But…
While I haven’t looked into it, the ‘include’ definition may only include those two posts and not the others from the author. You’d have to check yourself.
If it doesn’t work the best thing to do is two separate calls and then combine the two post arrays into one. It’s a bit more custom work, but that might be the way to get it sorted out.
What you present is what I initially tried, but it actually returned no posts. I thought that maybe it was because setting it up this way makes it look for the intersection of these two things: a post that is one of those two listed, AND that matches the meta query. Maybe not, but it seemed to explain why no posts were returned.
If I go the other route, can I just merge the two arrays? Any tips on getting them interleaved as if they came out as the result of one query, rather than the ‘include’ ones just being glommed on at the beginning or end?
Most parameters in WP_Query get logically ANDed, it’s likely what’s happening here. You want OR logic, but the only way to get that with WP_Query is to alter the actual SQL string via the “posts_request” filter. Query string manipulation is inherently weak IMO, but it is a possible solution.
Or you could compose your own SQL and not use WP_Query. Making two queries and merging is a reasonable solution as long as the queries aren’t taking too long to execute. But merging while maintaining sort order can become difficult if the results are paginated. If not paginated, you could combine the results, then usort() the combined array. Another way would be to keep separate results arrays and alter the output loop to appropriately slip in results from the second array during output.
.