Display custom texonomy name into post
Thu Jul 06 2023 11:30:04 GMT+0000 (Coordinated Universal Time)
Saved by
@gshailesh27
<?php
$loop = new WP_Query( array( 'post_type' => 'projets', 'posts_per_page' => '1' ) );
if ( $loop->have_posts() ) :
while ( $loop->have_posts() ) :
$loop->the_post(); // get all of the terms for this post, with the taxonomy of categories-projets. $terms = get_the_terms( $post->ID, 'categories-projets' );
the_title(); // create the span element, and write out the date this post was created. echo "<span>" . the_date();
foreach ( $terms as $term ) { echo $term->name; } echo "</span>";
endwhile;
wp_reset_query(); endif;
?>
content_copyCOPY
Comments