WordPress Получите таксономию поста
//Get all terms (names) of a taxonomy of a post
$term_obj_list = get_the_terms( $post->ID, 'taxonomy_name' ); ?>
gtamborero
//Get all terms (names) of a taxonomy of a post
$term_obj_list = get_the_terms( $post->ID, 'taxonomy_name' ); ?>
// RETRIVE TERM SLUG ( for single.php or template-part )
$terms = get_the_terms( $post->ID, 'your-taxonomy' );
if ( !empty( $terms ) ){
// get the first term
$term = array_shift( $terms );
echo $term->slug;
}
<?php
$taxonomy = 'my_taxonomy'; // this is the name of the taxonomy
$terms = get_terms($taxonomy);
$args = array(
'post_type' => 'post',
'tax_query' => array(
array(
'taxonomy' => 'updates',
'field' => 'slug',
'terms' => wp_list_pluck($terms,'slug')
)
)
);
$my_query = new WP_Query( $args );
if($my_query->have_posts()) :
while ($my_query->have_posts()) : $my_query->the_post();
// do what you want to do with the queried posts
endwhile;
endif;
?>
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;