Support

Account

Home Forums ACF PRO Manipulate taxonomy position with image in repeater

Helping

Manipulate taxonomy position with image in repeater

  • Hello everyone, I use this code that I set up to use the image within the taxonomy and I can make it appear within the related custom post types. However, I can not choose which position I want to appear in the order. I thought the repeater field would be the best solution. My thinking is this:
    When creating a taxonomy it is only necessary to write the name of the taxonomy, in case it is actor and choose the name of the actor that the image will appear. However, if the actor does not have an image I can already replace it with the upload field. What I can not do at the moment; is to be able to manipulate the positions of the repeating fields. Could someone point the way?

     <ol class="people scroller">
          <?php $terms = get_the_terms( $post->ID, 'actor', array('fields' => 'ids') );			$count = 1; foreach ( $terms as $term ) {
           $term_link = get_term_link( $term );
           if ( is_wp_error( $term_link ) ) {
           continue;
           }
    
    	// image id is stored as term meta
    	$image_id = get_term_meta( $term->term_id , 'image', true );
    	
    	// image data stored in array, second argument is which image size to retrieve
    	$image_data = wp_get_attachment_image_src( $image_id, 'full' );
    	
    	// image url is the first item in the array (aka 0)
    	$image = $image_data[0];
    
    	echo '<li class="card" style="padding: 0 0 22px 0 !important;">
    	   <a href="' . esc_url( $term_link ) . '">';
    
    	if ( ! empty( $image ) ) {  echo '<img src="' . esc_url( $image ) . '" />';
    	}
    	// imagem padrao caso o ator não tenha imagem de perfil.
    else{
      echo '<img class="profile fade lazyautosizes lazyloaded" src="'.get_template_directory_uri() . '/images/user-default.jpg'.'" />';
    } 
          
    	  echo '<p class="actor-person text-center">'. $term->name . '
    </a>
    	   </li>'; $count++;
        if ($count > 7) {
          break;
        }
           }
          ?>
        </ol>
Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.