We can get multiple posts manually in a page, but that’s generated in a template, AFTER the default query returned something else (page/post, etc)
How do you query multiple posts in a public query, which share no taxonomy or anything else?
e.g. by ID:
http://example.com/?p=23,18,2,199,6,8
I got it working already parsing a variable in a page-name.php template, but once it gets the template it’s too late to generate e.g. canonicals.
I guess this would be something similar to a search, except the search is a 1-to-multiple-posts relation and this requires a multiple-queries-to-unique-post (each).
Thanks.
Maybe you’re looking for the
post__in
parameter inWP_Query
.And then:
Take a look at the docs. =D
For public queries:
post__in
is not public queryable by default, so you can just validate and copy$_GET['post__in']
on theparse_query
action hook, and let the thing happen.Then you would just access this:
Please note that, like this, you won’t be able to set the post order in WordPress versions before 3.5 (#13729). Use this plugin if you need to.