Support

Account

Home Forums Front-end Issues Custom taxonomy acf value in loop on other pages Reply To: Custom taxonomy acf value in loop on other pages

  • Can you show your code please?

    And to clarify, the taxonomy is called floor4
    This is linked to a CPT of flat4
    The ACF field is called hover and it’s this value you’re trying to get?

    Does this work:

    global $wp_query;
    $paged = get_query_var('paged') ? get_query_var('paged') : 1;
    $args = array(
    	'posts_per_page' => -1,
    	'post_type'		=> 'flat4',
    	'paged' 		=> $paged,
    	'fields' 		=> 'ids'			
    );
    $wp_query = new WP_Query($args);
    if ($wp_query->have_posts()) :
    	while ($wp_query->have_posts()) : $wp_query->the_post();
    
    		$taxonomies = get_terms( array(
    			'taxonomy' => 'floor4',
    			'hide_empty' => false
    		) );
    
    		if ( !empty($taxonomies) ) :
    
    			foreach( $taxonomies as $category ) {
    				$hover= get_field('hover', 'term_' .$category->term_id  );
    				echo $hover;
    			}
    
    		endif;
    
    	endwhile;
    endif; wp_reset_query();