I’m trying to get all posts that have a specific tag, regardless of what type of post that is. I’ve tried every solution I’ve found (here on SO and further), but nothing works: I always only get the normal ‘post’ type from my wp_query.

I’ve tried this:

$query_args = array(
        'tag' => $tag,
        'post_type' => array('post', 'praktijk', 'expert', 'download', 'product', 'event')
    );

    $query = new WP_Query( $query_args );

And I would think that would work. Replacing the array of post_types with the string ‘any’ also doesn’t work.

Does anybody know what I’m doing wrong?

1 Answer
1

You could use

$query_args = array(
    'tag' => $tag,
    'post_type' => 'any',
);
$query = new WP_Query( $query_args );

Please have a look here: Tag Parameters and Type Parameters.

Leave a Reply

Your email address will not be published. Required fields are marked *