How can I add custom fields to product category? I have added custom field to product but I can’t find any extension which provide facility to add custom field to product category.
Leave a Reply
You must be logged in to post a comment.
How can I add custom fields to product category? I have added custom field to product but I can’t find any extension which provide facility to add custom field to product category.
You must be logged in to post a comment.
UPDATED on 17-Feb-2017
###For WP version
4.4
and above.As of WordPress 4.4,
update_term_meta()
andget_term_meta()
functions have been added. This means that now we don’t have to save the data inwp_options
table anymore, rather they are now stored inwp_termmeta
table.Here is my updated code.
USAGE, to retrive data:
###For WP version below `4.4`.
Here is the code
USAGE, to retrive data:
This code goes in function.php file of your active child theme (or theme) or also in any plugin file.
All code is tested, and fully functional.
Reference
Official Doc:
Starting WordPress 4.4 you should consider waiting for an upgrade of Woocommerce or starting feeding manually the new wp_termmeta table.
https://core.trac.wordpress.org/ticket/10142
There is an issue on code for WP version 4.4 and above.
When you change anything (f.e. url slug or name) on category list admin page the custom field value changes to empty string.
I added saving function for editing which does not execute on category edit admin page: