Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Filter products categories by ACF field #397

Open
fredoche1810 opened this issue Jan 6, 2022 · 0 comments
Open

Filter products categories by ACF field #397

fredoche1810 opened this issue Jan 6, 2022 · 0 comments

Comments

@fredoche1810
Copy link

Hello,
I try to filter the list of categories of the products received by the rest api.
I add 'myfield' as ACF field.
With the plugin ACF-to-rest-api I can see the field in the rest api result under acf : {}

This url returns all the categories.
https://mywebsite/wp-json/wc/v3/products/categories/

I want to be able to filter a custom field added by ACF
https://mywebsite/wp-json/wc/v3/products/categories/?myfield=testvalue

Could someone help me ?

I suppose there is a filter or an action to add in the functions.php file but everything I tried returned all the categories without any filter.

What’s also strange, for the products, I can see in the rest api result the metadata with the values added by ACF
For the category, the metadata aren’t visible.
In the database the values are stored in termmeta for the categories and in postmeta for the products.
If I’m right, the product is a post and the category is a taxonomy.

Thanks in advance,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant