Support

Account

Forum Replies Created

  • Edit the right code :

    					<?php $args = array(
    						'taxonomy' => 'marques-produits',
    					    'orderby' => 'name',
    					    'order'   => 'ASC'
    					    );	
    					$cats = get_categories($args);
    					foreach($cats as $cat) {
    						$logo = get_field('logo_marque', 'marques-produits_'. $cat->term_id .'');
    						echo 
    						'<a href="' . get_category_link( $cat->term_id ) . '" title="' . sprintf( __( "Voir tout les produits %s" ), $cat->name ) . '">
    							<img src="' . $logo['url']; ?>" alt="<?php echo $logo['alt'] . '">
    						</a>';
    						}
    					?>
    
  • I finally found out the solution. I was wrong from the start. This code works for me, it can probably be optimized

    <?php
    	$args = array(
    		'taxonomy' => 'marques-produits',
    	    'orderby' => 'name',
    	    'order'   => 'ASC'
    	    );	
    	   $cats = get_categories($args);
    	   foreach($cats as $cat) {
    		   
    		   if ($logo = get_field('logo_marque','marques-produits_'.$cat->term_id)) {
    			   $cats_keep[] = $cat;
    			   }
    			}
    			foreach($cats_keep as $cat) {
    		   
    	?>
    	      <a href="<?php echo get_category_link( $cat->term_id ) ?>">
    	           <img src="<?php echo esc_url($logo['url']); ?>" alt="<?php echo esc_attr($logo['alt']); ?>" />
    	      </a>
    	<?php
    	   }
    	?>
    
  • I created a taxonomy ‘marques-produit’ for my CPT ‘produits’. I used ACF to add the field image ‘logo_marque’ on my taxonomy.
    Now I want to display on my front page the field ‘logo_marque’ for every label like this
    <img src="<?php echo esc_url($logo['url']); ?>" alt="<?php echo esc_attr($logo['alt']); ?>" />
    Thank you

  • It’s not exactly what I want. But I find out the solution :

    <?php 	$field = get_field_object('equipement');
    	$equipements = $field['choices'];
    	$equipements_selected = $field['value'];							
    	if (sizeof($equipements_selected)>0) {
    	?>
    	<ul>
    	<?php foreach($equipements_selected as $equipClass) {
    		$equipLabel = $equipements[$equipClass];
    	?>
    	<li class="<?php echo $equipClass; ?>"><?php echo $equipLabel; ?></li>
    	<?php	} // foreach ?>
    	</ul>
    	<?php 	} // if sizeof ?>

    Thank you for your answer.

Viewing 4 posts - 1 through 4 (of 4 total)