Taxonomy, post by term
-
Hello,
I’ve been looking for the solution to this problem for hours … unfortunately I have not found.
After creating a “custom post type” (with taxonomy) – I created a group of fields to the taxonomy (for this taxonomy only).
After several unsuccessful searches, I ask my question here. Indeed, I’m trying to display a list of posts grouped by categories:
CAT A
post1
post2
post3
CAT Bpost4
post5
post6
post7 ..Someone could help me please?
Custom post type: client
Name of taxonomy: secteur
Custom field on taxonomy: secteur_dactivite<?php $terms = get_terms( 'secteur', array( 'orderby' => 'count', 'hide_empty' => 0 ) ); foreach( $terms as $term ) { $args = array( 'post_type' => 'client', 'posts_per_page' => '-1', 'secteur' => $term->slug ); $query = new WP_Query( $args ); echo'<h3>' . $term->name . '</h3>'; // Start the Loop while ( $query->have_posts() ) : $query->the_post(); $secteur_dactivite = get_field( 'secteur_dactivite' ); echo '<div class="cat-'.esc_html( $secteur_dactivite->slug ). '"><img src="'.get_field( 'logo' ).'"></div>'; endwhile; wp_reset_postdata(); } ?>
Viewing 8 replies - 1 through 8 (of 8 total)
Viewing 8 replies - 1 through 8 (of 8 total)
The topic ‘Taxonomy, post by term’ is closed to new replies.