Answers for "get taxonomy with post id"

PHP
7

wordpress get taxonomy of a post

//Get all terms (names) of a taxonomy of a post
$term_obj_list = get_the_terms( $post->ID, 'taxonomy_name' ); ?>
Posted by: Guest on July-09-2020
0

get post by taxonomy

foreach ($myterms as $term) :

$args = array(
    'tax_query' => array(
        array(
            $term->slug
        )
    )
);

//  assigning variables to the loop
global $wp_query;
$wp_query = new WP_Query($args);

// starting loop
while ($wp_query->have_posts()) : $wp_query->the_post();

the_title();
blabla....

endwhile;

endforeach;
Posted by: Guest on November-09-2021

Browse Popular Code Answers by Language