Archived topic
Add image on categories
13 replies · Started by Alfonso on January 5, 2021
Hi there,
I’ve added a image to categories with ACF plugin, is possible to display it on my Archive blog sidebar?
https://www.delahuertacasa.com/blog/
And how i can display empty categories on sidebar??
Thanks!
Hi there,
You could create a new Hook Element and set it to generate_before_right_sidebar_content.
Then add the ACF code to output the image.
As for the empty categories, this should help: https://www.wpbeginner.com/wp-tutorials/how-to-show-empty-categories-in-wordpress/#:~:text=Inside%20our%20function%20we%20have,display%20empty%20categories%20as%20well.
Thank you Tom, but i don't understand you.
I can create a hook, but What should I put inside?
https://snipboard.io/oLqw6C.jpg
Then I have ACF configured like this, isn't it correct?
https://snipboard.io/74uCp0.jpg
Now, my category having a image:
I can create a hook, but What should I put inside?
You need to add the ACF shortcode that contains the image for the category on the code text area within the Hook element.
If you're not familiar with ACF shortcodes, refer to this documentation:
https://www.advancedcustomfields.com/resources/shortcode/
You then set the Hook Element's hook to generate_before_right_sidebar_content and set the display rule location to "All Archive".
Hi Elvin,
I've added this shortcode: [acf field="imagen"]
but only get this:
https://snipboard.io/EAfT8W.jpg
The goal is to get my categories to display with your image, like this example:
To verify: Is the Execute Shortcodes setting on the Hook Element checked? You have to check it so that the added shortcodes execute.
https://docs.generatepress.com/article/hooks-element-overview/#settings
Sorry, now "execute shortcode" is enabled but images are noy dispaying
Sorry, now “execute shortcode” is enabled but images are noy dispaying
Let's test if the shortcode works.
Can you try testing the same shortcode on a Shortcode block placed on content?
Does it display anything? Let us know.
I've added the shortcode at the end of my single post and is not working.
[acf field="imagen"]
My custom field is named "imagen"
Hi there,
are you wanting to display an image beside each of the category links ?
If so then maybe this ACF topic will help:
https://support.advancedcustomfields.com/forums/topic/category-list-with-thumbnails/
Hi there,
I'm a bit lost on this.
I want to try another method following this documentation but it doesn't work either. I have added a snippet to activate the thumbnail button but nothing appears
Snippet with this code: add_theme_support('category-thumbnails');
Are you trying to add the images to the sidebar links - see example image ie. red boxes:

Yes but i can't do it.
The idea is to get this widget without plugins. To achieve this I had to install 2 plugins.
Now you can view at first time, categories without featured image or thumbnails and new widget with the same categories and his featured images.
The Category Widget that WordPress has built in doesn't have any filters, so there is no way to insert the category images in there.
The only way to do this is either a Plugin ( like Advanced Category Widgets ) or to have it Custom Developed. If the plugin works and provides the features you require then i would use the plugin.