How to index Tags in attached images in Wordpress Plugin?

The Tag attached to image won’t work if I don’t attach my image to my gallery. I want my user upload their images and add Tag for each uploaded images in front-end. But, it seems Algolia cannot index Tags if image is not attached to any gallery. How can I fix this problem? or Maybe there is a bug in your code.


Hi there,

Natively WordPress doesn’t provide tags for attachments.

In your case, could it be that a third party plugin introduces that?

If this is specific to a plugin you have, you can still push the custom data by inspiring yourself from:

I hope that helps,
I’d gladly see a screenshot of an admin screen where you manage attachment tags to better understand,



Thank you for your comment.

I know wordpress doesn’t have tags features in Meida Library and I added this feature with my custom Plugin in worpress, here is appearance of my Media Library The “Blink”,“Cat”, “Orange” Tags are attached to Cat photo and cat photo is attached to JIG gallery (see the link above), in this case I was able to index all Tags in Algolia list in managing index here is the link But, when I uploaded another image in Media Library without attaching to any Gallery, I wasn’t able to Index any of these Tags, please see the follwoing link: for better understanding.

The question is why I am not able to index Tags if there are not attached to any Gallery? if the tags just attached to photos, algolia plugin should able to index these tags.



it might be related to the fact that by default we don’t index terms if they are attached to no items:

If that is the issue in your case, you can override that behaviour by returning true from the algolia_should_index_term hook.

Here are examples:

In your case, this might do the trick:

add_filter( 'algolia_should_index_term', '__return_true' );

You will need to re-index terms after adding this code.

I hope it helps.

1 Like


Thank you for your comment.

Can you please tell me where to put this code in your plugin code? Please give me the name of your php file in your plugin and screenshot of which line.


You can add that line to the functions.php file of your active theme.

Please note that I can not know for sure that this will indeed solve your issue.
My solution is a guess based on the shared information.

If it doesn’t work, you’ll have to ask for some WordPress developer help or ask the authors of the plugin you are using.


1 Like

Awesome! it worked like a charm!

Do you have a plan for Auto indexing in future plugin release?


1 Like