• Hello
    This plugin is exactly what I am looking for, unfortunately it doesn’t work for me.
    I have products (custom post types) and a taxonomy to group all of them in a custom categories.
    I have template for a single product and a template for the taxonomy.
    I have an additional template which displays all the terms created inside a nice layout.
    I wanted to be able to show image associated with a taxonomy term so I used “Taxonomy Images” plugin but I can’t figure out how to display the image associated with a term inside my template
    here is my code that displays a loop of all terms created automatically:

    <?php $args = array('taxonomy' => 'products'); ?>
    <?php $tax_menu_items = get_categories( $args );
    foreach ( $tax_menu_items as $tax_menu_item ):?>
    <div class="box">
    <h2><?php echo $tax_menu_item->name; ?></h2>
    <a href="<?php echo get_term_link($tax_menu_item,$tax_menu_item->taxonomy); ?>">
    <img src="<?php bloginfo('template_directory'); ?>/images/Mahit_135px.png" alt="" />
    </a>
    <p>
    <?php echo $tax_menu_item->description; ?>
    </p>
    </div>
    <?php endforeach; ?>

    there is an image inside the loop (just a sample image for now)
    I would like to know what line of code should I replace the sample image with in order to display the taxonomy term image uploaded via the plugin.

    Thanks
    GIl

    http://wordpress.org/extend/plugins/taxonomy-images/

Viewing 2 replies - 1 through 2 (of 2 total)
  • <?php $args = array('taxonomy' => 'products'); ?>
    <?php $tax_menu_items = get_categories( $args );
    foreach ( $tax_menu_items as $tax_menu_item ):?>
      <?php
      $tax_term_id = $tax_menu_item->term_taxonomy_id;
      $images = get_option('taxonomy_image_plugin');
      ?>
      <div class="box">
        <h2><?php echo $tax_menu_item->name; ?></h2>
        <a href="<?php echo get_term_link($tax_menu_item,$tax_menu_item->taxonomy); ?>">
        <?php wp_get_attachment_image( $images[$tax_term_id], 'medium' ); ?>
        </a>
        <p>
          <?php echo $tax_menu_item->description; ?>
        </p>
      </div>
    <?php endforeach; ?>

    That should do the trick. Here we’re getting the term taxonomy id for the loops current iteration, and pulling the images stored in the plugins option.

    Then we replace your sample image with the attachment (for that iterations ID).

    A quick note for you, or anyone else having problem displaying the image… if you’re building this without content, be sure to turn “hide_empty” off in your get_categories() arguments.

    <?php get_categories(array('taxonomy'=>'your-custom-taxonomy', 'hide_empty'=>0)); ?>
    Thread Starter hamergil

    (@hamergil)

    Thanks for the answer
    unfortunately it didn’t work in my case.
    I found a different solution in my project.
    I might try to use this plugin again for my next project
    and see if it works

    Thanks a lot
    Gil

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘[Plugin: Taxonomy Images] Cant get the image to display in my theme’ is closed to new replies.