Created
April 30, 2020 07:14
-
-
Save platoosom/7f80093e58523b11028695396073a720 to your computer and use it in GitHub Desktop.
Wordpress get custom post by custom tags.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$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