Answers for "wordpress get posts taxonomy term"

PHP
4

wordpress get taxonomy of a post

<?php $term_obj_list = get_the_terms( $post->ID, 'taxonomy_name' ); ?>
Posted by: Guest on July-09-2020
0

get posts by custom taxonomy wp_query

$the_query = new WP_Query( array(
    'post_type' => 'Adverts',
    'tax_query' => array(
        array (
            'taxonomy' => 'advert_tag',
            'field' => 'slug',
            'terms' => 'politics',
        )
    ),
) );

while ( $the_query->have_posts() ) :
    $the_query->the_post();
    // Show Posts ...
endwhile;

/* Restore original Post Data 
 * NB: Because we are using new WP_Query we aren't stomping on the 
 * original $wp_query and it does not need to be reset.
*/
wp_reset_postdata();
Posted by: Guest on July-08-2021

Code answers related to "wordpress get posts taxonomy term"

Browse Popular Code Answers by Language