Sign up ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I'm trying to display posts within the WP loop and am able to successfully do so with <?php query_posts('tag_id=10'); ?> Here the loop will display all posts with the tag ID of 10, but I'd also like the loop to display posts from within a Custom Post type by the same tag.

I'm able to successfully display posts with tag_id=10 that originate from a custom post type using <?php query_posts('tag_id=10&post_type=videos'); ?>

But how can I merge the two?

I gave this a shot: <?php query_posts('tag_id=10', 'tag_id=10&post_type=videos'); ?> but that had no effect (well actually it broke everything!)

share|improve this question

1 Answer 1

up vote 0 down vote accepted

may i suggest you use instead get_posts()?


$args_t10 = array(
  'tag_id' => 10,
$postslist_t10 = get_posts( $args_t10 ); ?>

$args_t10_v = array(
   'tag_id' => 10,
   'post_type' => 'videos'
$postslist_t10_v = get_posts( $args_t10_v );

you then can merge and filter the duplicates

$postmixed = array_merge($postslist_t10, $postslist_t10_v);
$uniqueposts = array_unique(postmixed);


wp: get_posts() and parameters

php: array-unique() , array_merge

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.