Skip to content

Instantly share code, notes, and snippets.

@ericandrewlewis
Last active December 31, 2015 09:49
Show Gist options
  • Save ericandrewlewis/7969351 to your computer and use it in GitHub Desktop.
Save ericandrewlewis/7969351 to your computer and use it in GitHub Desktop.
<?php
$term = get_term_by( 'slug', get_query_var( 'pro' ), "post_tag" );
$tagslug = $term->slug;
$ukposts = get_posts( array(
'posts_per_page' => -1,
'post_type' => 'uk',
'post_status' => 'publish'
) );
$proposts = get_posts( array(
'posts_per_page' => -1,
'post_type' => 'post',
'tag' => $tagslug,
'post_status' => 'publish'
) );
$merged_IDs = array_merge(
wp_list_pluck( $proposts, 'ID' ),
wp_list_pluck( $ukposts, 'ID' )
);
$merged_IDs = array_unique($merged_IDs);
$posts = get_posts( array(
'post_type' => array( 'uk', 'post' ),
'post__in' => $merged_IDs,
'post_status' => 'publish'
) );
foreach($posts as $post) :
setup_postdata($post);
var_dump($post);
endforeach; ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment