T
T
thehighhomie2016-01-26 21:47:40
WordPress
thehighhomie, 2016-01-26 21:47:40

Displaying a category thumbnail?

How to display category thumbnail? For example, there is a menu with categories, registered in functions.php, and you need to display thumbnails in the menu as well. How can this be implemented? I repeat once again, it is the output of miniatures of headings.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
I
imdeveloper, 2016-01-27
@link_web

in functions.php

// добавляем шорткод cat_desc, который будет заменен результатом выполнения функции cat_desc()
add_shortcode( 'cat_desc', 'cat_desc' );
// разрешаем выполнение шорткода в описаниях
add_filter( 'term_description', 'do_shortcode' );
function cat_desc($attr, $text=''){
  echo '<div class="cat-desc">';
  echo "<img class='wp-post-image' src='{$attr['src']}' alt=''>";
  echo $text;
  echo '</div>';
}

And then insert the thumbnail url into the category description, and display it in the right place, for example, in the category template:
<?php echo category_description(); ?>

I
Igor Vorotnev, 2016-01-27
@HeadOnFire

So there are a lot of plugins . I even have my custom one lying around somewhere, I recently wrote. By the same principle as the others, it only uses the new wp_termmeta table. I can put it on GitHub, if anything.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question