• Resolved Joelle

    (@joelle)


    Hello, I have a client who is using a builder, so I’m not able to drop in the php snippet in a usual way.

    My goal is to drop it into the builder via PHP shortcoder and have it display the category image associated with that post. But I’m not sure if that’s possible. I’m able to do that with displaying the taxonomy names, but I’m not able to get it to display anything when I try with your snippet.

    Do you have any work arounds that might help with this? I’ve googled significantly, but all the solutions aren’t taking into account a single post, for that one post. I can loop through them and it’ll show me all the category images for all the posts, but not just for hte one we’re looking at.

    Do you have any ideas that might help? 🙂 Thank you!

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter Joelle

    (@joelle)

    I got this resolved by doing this:

    <ul class="author-photo">
    <?php foreach (get_the_terms(get_the_ID(), 'book_author') as $cat) : ?>
    <li>
    <a href="<?php echo get_term_link($cat->term_id, 'book_author'); ?>"><img src="<?php echo z_taxonomy_image_url($cat->term_id, 'medium'); ?>" /></a>
    <a href="<?php echo get_term_link($cat->term_id, 'book_author'); ?>"><span><?php echo $cat->name; ?></a></span></a>
    </li>
    <?php endforeach; ?>
    </ul>

    I am still struggling to get the correct size of the image to display (medium), but it’s finally working and I’m happy. 🙂

    Hi , Please tell me Where file in theme this part of code to put in?

    Best Regard,

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Display Category Image on a SIngle Post’ is closed to new replies.