Categories Images
[resolved] Sub categories (5 posts)

  1. zactoff
    Posted 2 years ago #

    This doesn't seem to work with sub-categories. If their parent has an image assigned, and the sub-category has an image assigned, nothing shows up on the single post using the provided code. Is there something else I should be doing?


  2. Muhammad
    Plugin Author

    Posted 2 years ago #

    Sorry for my late reply.

    You can display post categories using the 1st loop example in the plugin docs with get_the_category()

  3. zactoff
    Posted 2 years ago #

    No worries, thanks for the reply, but I don't think you've answered my questions, it's about displaying images for sub-categories, can you provide a code example?

  4. Muhammad
    Plugin Author

    Posted 2 years ago #

    assume you are in a single post, all you have to do is to get this post categories using get_the_category() then loop on it to display categories images, for example:

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

    Hope I helped.

  5. zactoff
    Posted 2 years ago #

    Thanks I will test when I get a chance, however the project I needed it for finished ages ago so I had went with a different solution.

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • Categories Images
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic