Skip to content

Instantly share code, notes, and snippets.

@platoosom
Created April 30, 2020 07:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save platoosom/7f80093e58523b11028695396073a720 to your computer and use it in GitHub Desktop.
Save platoosom/7f80093e58523b11028695396073a720 to your computer and use it in GitHub Desktop.
Wordpress get custom post by custom tags.
$terms = get_the_terms( get_the_ID(), 'podcast-tag' );
if ( $terms && is_array( $terms ) ) {
foreach ( $terms as $term ) {
$termlists[] = $term->slug;
}
}
$query_args = array(
'post_type' => 'podcast',
'post_status' => 'publish',
'posts_per_page' => 3,
'tax_query' => array(
array(
'taxonomy' => 'podcast-tag',
'field' => 'slug',
'terms' => $termlists,
),
)
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment