filter custom post in rest api with custom function

admin2025-01-08  3

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

Share Improve this question asked May 2, 2018 at 10:43 ebeliejinfrenebeliejinfren 1598 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 0

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.

转载请注明原文地址:http://conceptsofalgorithm.com/Algorithm/1736270092a1402.html

最新回复(0)