i have 3 custom post type : artists, songs, videos songs and videos have a meta that sort artist id of songs or videos filter in rest api couldn't return filtered post by artist id custom meta
so i have to return that by custom function and show it in rest api
how create a function that compare value of artist id meta and return post that have specific artist id ?
something like this : /wp-json/wp/v2/songs?artist=4438 that return songs that meta value of artist is 4438
thanks
i have 3 custom post type : artists, songs, videos songs and videos have a meta that sort artist id of songs or videos filter in rest api couldn't return filtered post by artist id custom meta
so i have to return that by custom function and show it in rest api
how create a function that compare value of artist id meta and return post that have specific artist id ?
something like this : /wp-json/wp/v2/songs?artist=4438 that return songs that meta value of artist is 4438
thanks
I mean you need to query by your custom taxonomy (eg. songs_categories
, or whatever you named it in your register_taxonomy()
function) and then by the term.
&filter[taxonomy]=songs_categories&filter[term]=artist
PS: In my context I filter via custom filter, a plugin that enhance the API. You find all information on the repo.