WordPress.org

Ready to get started?Download WordPress

Forums

Categories Images
[resolved] Sub categories (5 posts)

  1. zactoff
    Member
    Posted 10 months 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?

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

  2. Muhammad
    Member
    Plugin Author

    Posted 8 months 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
    Member
    Posted 8 months 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
    Member
    Plugin Author

    Posted 8 months ago #

    :)
    ok
    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:

    <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>

    Hope I helped.

  5. zactoff
    Member
    Posted 8 months 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.

Reply

You must log in to post.

About this Plugin

About this Topic