Created
April 30, 2020 07:16
-
-
Save platoosom/8043b4c70f2434911f647ad3ea7a68ca to your computer and use it in GitHub Desktop.
Wordpress query not include current post
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
$termlists = array(); | |
$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, | |
), | |
), | |
'post__not_in' => array(get_the_ID()) | |
); | |
$query = new WP_Query( $query_args ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment