• Resolved delpatiolongboarding

    (@delpatiolongboarding)


    Having troubles implementing the code, needing some help.

    How can i call the image of the category in a single post of my custom post type.

    Im trying to use:

    <?php foreach (get_terms('your_taxonomy') as $cat) : ?>
     <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>
     <?php endforeach; ?>

    all the images come from subcategories…

    https://wordpress.org/plugins/categories-images/

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

    (@elzahlan)

    No, you should use the following example:

    <ul>
     <?php foreach (get_the_category() as $cat) : ?>
     <li>
     <img src="<?php echo z_taxonomy_image_url($cat->term_id); ?>" />
     <a href="<?php echo get_category_link($cat->term_id); ?>"><?php echo $cat->cat_name; ?></a>
     </li>
     <?php endforeach; ?>
    </ul>

    For me that is only showing the category itself, the name and the hyperlink, not the image. What can I be doing wrong?

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘How to display category image inside a single post of a custom post type?’ is closed to new replies.