• itsmemary

    (@itsmemary)


    After an entire day of googling and trying a bunch of different things I sort of have what I want.

    I am trying to display a list of taxonomy terms with the images inside links. With the Taxonomy Images plugin, and random people’s code I now have two lists on my page. One is a list of the taxonomy terms with the links, the other is a list of the images, no links. I need to combine these two so that I am able to display a list of the taxonomy terms, and the image, inside a link. I am not knowledgable enough in php to know how to do this, plus my brain is fried. Please help!

    //list of terms with links
    <?php
    	$taxonomy = 'series';
    	$tax_terms = get_terms($taxonomy);
    ?>
    	<ul>
    		<?php
    		foreach ($tax_terms as $tax_term) {
    			echo '<li>' . '<a href="' . esc_attr(get_term_link($tax_term, $taxonomy)) . '" title="' . sprintf( __( "View all posts in %s" ), $tax_term->name ) . '" ' . '>' . $tax_term->name.'</a></li>';
    		}
    		?>
    		</ul>
    
    //list of images
       		<?php
    		$terms = apply_filters( 'taxonomy-images-get-terms', '', array('taxonomy' => 'series') );
    		foreach( (array) $terms as $term) {
    			echo wp_get_attachment_image( $term->image_id, 'destacado-proyectos-home' );
    		}
    		?>

    https://www.ads-software.com/plugins/taxonomy-images/

Viewing 1 replies (of 1 total)
  • Plugin Author Ben Huson

    (@husobj)

    Try this:

    <?php
    
    // List of image links
    
    $terms = apply_filters( 'taxonomy-images-get-terms', '', array( 'taxonomy' => 'series' ) );
    
    foreach( (array) $terms as $term) {
    	echo '<a href="' . esc_attr( get_term_link( $term ) ) . '" title="' . sprintf( __( "View all posts in %s" ), $term->name ) . '" ' . '>' . wp_get_attachment_image( $term->image_id, 'destacado-proyectos-home' ) . '</a>';
    }
    
    ?>
Viewing 1 replies (of 1 total)
  • The topic ‘Display Taxonomy Name Images with link’ is closed to new replies.