Home Forums ACF PRO Callback within the post for a taxonomy


Callback within the post for a taxonomy

  • Hello, great contributors to ACF. Currently I use this function to call the images I add within a taxonomy to appear in the post referring to the same taxonomy. I thought I could tie callback to that by adding inside the post itself. The images were also recorded directly in the taxonomy, to appear in the posts. Without the need to go in each taxonomy and add an image referring to the names of the actors. Could someone point the correct way to this?

      <?php $terms = get_the_terms( $post->ID, 'actors' );			$count = 1; foreach ( $terms as $term ) {
           $term_link = get_term_link( $term );
           if ( is_wp_error( $term_link ) ) {
    	// 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.
      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 . '</p></a>
    	   </li>'; $count++;
        if ($count > 7) {
Viewing 1 post (of 1 total)

You must be logged in to reply to this topic.