• Resolved dannytuan

    (@dannytuan)


    Hi !

    I have a custom taxonomy with 500+ terms.

    I use this script to get all terms

    <?php 
    $tax = 'dtcast'; // your taxonomy name
    
    // get the terms of taxonomy
    $terms = get_terms( $tax, [
    	'hide_empty' => false, // do not hide empty terms
    ]);
    
    // loop through all terms
    foreach( $terms as $term ) {
    	// display link to the term archive
    	echo '<strong class="danny-vien"><a href="'. get_term_link( $term ) .'">'. $term->name .'</a></strong>';
    }
    ?>

    It’s work ok !

    Now i want to get images of terms.
    Please help me to get it.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Sajjad Hossain Sagor

    (@sajjad67)

    Hi @dannytuan

    Documentation says it already… you need to use the function get_taxonomy_image( $term_id )

    Anonymous User 16824372

    (@anonymized-16824372)

    /**
     * Woo : Display Custom Product Taxonomy [Brand] Images in Sidebar
    */
    // Required Plugin: Advanced Category and Custom Taxonomy Image 
    
    function woo_new_product_tab_content() {
        global $product;
    	$tax = 'brand'; // your taxonomy name
    	$terms = get_terms( $tax, ['hide_empty' => false] );
    	echo '<h4 class="widget-title">BRANDS</h4>';
    	foreach( $terms as $term ) {
    		$taxonomy_img = get_taxonomy_image ($term->term_id);
    		// echo '<div class="taxo-text"><a href="'. get_term_link( $term ) .'">' . $term->name . '</a></div>'; // display taxo text
    		echo '<div class="taxo-image"><a href="'. get_term_link( $term ) .'">' . '<img src="'. $taxonomy_img  .'">' . '</a></div>'; // display taxo image 
    	}
    }
    add_action( 'ocean_before_sidebar_inner' , 'woo_new_product_tab_content' );
    
    Anonymous User 16824372

    (@anonymized-16824372)

    I use oceanWp theme. So you need to use the correct action hook for your sidebar.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Get Custom Taxonomy Images’ is closed to new replies.