Hello,
I'm trying to do something interesting but Google is not providing any answers. I thought maybe someone has done this before or perhaps could figure it out.
I want to run multiple queries and compile them all into one loop. The reason is, I have tags that live in multiple custom taxonomies but are occasionally the same. I want my custom archive.php page to retrieve posts for all post types for the queried taxonomy term, no matter the taxonomies that it lives in.
For instance, on our blog/database of authors' homes, we have a News posts tagged "Edgar Allan Poe" and we have House Posts with the "author taxonomy" term "Edgar Allan Poe" for the Author sorting feature. In a couple places, I would like all posts with the term "Edgar Allan Poe" to be returned regardless of the taxonomy that holds it.
I can envision a something like
<?php
$posts = get_posts( array(
'tag' => $tagslug,
'post_type' => $post_types,
'post_status' => 'publish',
));
$posts .= get_posts( array(
'bookauthor' => $tagslug,
'post_type' => $post_types,
'post_status' => 'publish',
));
foreach($posts as $post) :
setup_postdata($post);
?>
but that is an invalid argument for foreach
Any idea how one would compile the results of multiple queries, disregard duplicates, and return the results in a loop?
Thanks!