• Resolved robertodimarco

    (@robertodimarco)


    Hello! I’ve this code for generating a hierachical list of taxonomies :

    <?php
        	$taxonomy = 'finiture'; // change this to your taxonomy
        	$terms = wp_get_post_terms( $post->ID, $taxonomy, array( "fields" => "ids" ) );
        	if( $terms ) {
        	  echo '<ul>';
    
        	  $terms = trim( implode( ',', (array) $terms ), ' ,' );
        	  wp_list_categories( 'title_li=&taxonomy=' . $taxonomy . '&include=' . $terms );
    
        	  echo '</ul>';
        	}
        	?>

    But i need to insert after each <li> elements this code :
    <img src="<?php echo z_taxonomy_image_url($cat->term_id); ?>"/>

    To have this structure :

    <ul>Name<ul>
    <li><a><img />Sub-name</a></li>
    <li><a><img />Sub-name</a></li>
    <li><a><img />Sub-name</a></li>
    </ul>

    I think that i need to change wp_list_categories() with another function…. i’m trying with no results…. Someone can help me? Thank u!

Viewing 1 replies (of 1 total)
  • Thread Starter robertodimarco

    (@robertodimarco)

    Solved! I’ve found this script:

    <?php
        	$args = array(
        	        'orderby'   => 'name',
        	        'order'     => 'ASC',
        	        'hide_empty'    => '0',
        	        'taxonomy' =>'finiture',
        	  );
    
        	$categories = get_categories($args);
    
        	foreach( $categories as $category ) { 
    
        	    $cat_ID = $category->term_id;
        	    $cat_name = $category->name;
        	    $cat_count = $category->count;
    
        	    echo '<p><strong>'.$cat_name.'</strong>';
    // here's my img
    echo '<img  src="'.z_taxonomy_image_url($category->term_id).'"/>';
        	    echo '</p>';  
    
        	}
        	?>

Viewing 1 replies (of 1 total)
  • The topic ‘help with custom hierachical list of taxonomies’ is closed to new replies.