Viewing 9 replies - 1 through 9 (of 9 total)
  • Plugin Author Muhammad

    (@elzahlan)

    have you checked the examples in the plugin documentation here ?
    I think what you need is the 4th one in using inside loop.

    check it and reply back if you still any help

    Thanks

    Thread Starter markyeoj

    (@markyeoj)

    I used this code.. but did not work,

    <div id="recipe-category" class="rolls">
    Recipe Category
    <ul>
     <?php foreach (get_terms('your_taxonomy') as $cat) : ?>
     <li>
     <img src="<?php echo z_taxonomy_image_url($cat->term_id); ?>" />
     <a href="<?php echo get_term_link($cat->slug, 'your_taxonomy'); ?>"><?php echo $cat->name; ?></a>
     </li>
     <?php endforeach; ?>
    </ul>
    </div>

    here’s the image

    Plugin Author Muhammad

    (@elzahlan)

    🙂
    for sure it won’t work cuz you have to change the word ‘your_taxonomy’ to your taxonomy name 🙂

    Thread Starter markyeoj

    (@markyeoj)

    ouch. haha.. sorry, I copied the wrong code..

    here’s the code from my template..

    <div id="recipe-category" class="rolls">
    Recipe Category
    
    <ul>
     <?php foreach (get_terms('recipecategory') as $cat) : ?>
     <li>
    <img src="<?php echo z_taxonomy_image_url($cat->term_id); ?>" />
    <a href="<?php echo get_term_link($cat->slug, 'your_taxonomy'); ?>"><?php echo $cat->name; ?></a>
    </li>
    <?php endforeach; ?>
    </ul>
    
    </div>
    Plugin Author Muhammad

    (@elzahlan)

    🙂 you still have to change the other ‘your_taxonomy’ word inside the loop

    Thread Starter markyeoj

    (@markyeoj)

    yes.. I already changed that.. looks like the problem is with the custom post type UI plugin.. even I use a simple

    <?php
    
    $taxonomy = 'recipecategory';
    $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>

    still not working.

    Plugin Author Muhammad

    (@elzahlan)

    you mean even without using my plugin ? if so, please make sure of the taxonomy name is the same name you had registered it with.

    Thread Starter markyeoj

    (@markyeoj)

    Yes even without using your plugin. this is very frustrating, I hope the support of Custom Post Type UI can help me to fix this.

    Try this updated code.
    You can remove the timthumb stuff if you don’t use that.

    // taxonomy term archives
    $post_type = get_post_type(); // find out if CPT
    $taxonomies = get_object_taxonomies($post_type); // Find taxonomies
    if($taxonomies){
    foreach($taxonomies as $taxonomy){
       // only want hierarchial -- no tags please
        if(is_taxonomy_hierarchical($taxonomy)){
    
            $terms = get_terms($taxonomy); // find out "terms" e.g. catoegries, for each taxonomy
    
    		// if($terms){
                foreach ( $terms as $term ) {  ?>
    
    <li>
    
                <h1><a href="<?php echo get_term_link($term->slug, $taxonomy); ?> "><? echo $term->name; ?></a></h1>
    
                <div class="imgBox">
                <? if (function_exists('z_taxonomy_image_url')) { ?>
    			<img src="<?php echo get_template_directory_uri(); ?>/timthumb.php?src=<?php echo z_taxonomy_image_url($term->term_id); ?>&h=196&w=285&zc=1" alt="<?php the_title(); ?>" />
                <?php } else { ?>
                    <img src="<?php echo get_template_directory_uri(); ?>/timthumb.php?src=/images/placeholder.png&h=196&w=285&zc=1" alt="<?php the_title(); ?>" />
                 <?	 } ?>
                </div>
    
                </li>
    
                <?	
    
              }
        }
    }
    }
Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘List the Custom Taxonomy with with image’ is closed to new replies.