Home Forums Front-end Issues ACF Taxonomies : Get just the used Terms in a DropDown


ACF Taxonomies : Get just the used Terms in a DropDown

    • PGK37

    • March 23, 2020 at 4:15 am


    I haven’t found an answer to my question yet …

    I’m looking for a solution to list “Terms” used in custom post in a dropdown (Name + Link).

    I created an ACF Taxonomy like on the screenshot below.

    From my custom post I chose the main Term (1 only) which will be displayed on my thumbnails in my list (Archive).

    I tried a loop here, I have the 10 terms used on all of my CPTs but the names and links are not displayed.

    					  	$taxonomies = get_field('thematique');
    					  	// args
    					  	$args = array(
    					  		'numberposts' => -1,
    					  		'post_type' => 'portfolio',
    					  		'tax_query' => array(
    					  				'taxonomy' => 'categoriesportfolio',
    					  				'field' => 'motscles',
    					  				'terms' => array()
    					  	if( $taxonomies )
    					  		foreach( $taxonomies as $term )
    					  			$args['tax_query']['terms'][] = $term->name;
    					  			$term_list .= '<a href="' . esc_url( get_term_link( $term ) ) . '" alt="' . esc_attr( sprintf( __( 'View all post filed under %s', 'my_localization_domain' ), $term->name ) ) . '" class="dropdown-item" >' . $term->name . '</a>';
    						 echo $term_list;
    					  	// get results
    				  		$the_query = new WP_Query( $args );

    Thanks for your help ! 🙂

Viewing 1 post (of 1 total)

You must be logged in to reply to this topic.

We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Cookie Policy. If you continue to use this site, you consent to our use of cookies.