last day (14 days later) » 

12:17 PM
0
A: How do I retrieve a list of posts based on a tag slug in WP Rest API V2?

linJust get the list of tags by calling http://demo.wp-api.org/wp-json/wp/v2/tags before your requesting posts on a specifiy tagId. In that way you will find the tagId you need by filtering the data by your "slug". The demo API is not support CORS thats way I dont create a working fiddle. Nested $h...

 
Thanks. I'll try to see it it works.
 
lin
@krillebimbim Does it work for you?
 
I have retrieved an object array with all the tags now. But I have troubles trying to match the tag 'slug' against the object array. I want to find the index of the right tag and return the id of this tag. Then I can use that to call the posts with a specific tag. This code does not give me the location: var tags = succ; pos = tags.indexOf('baevresvamp');
 
lin
@krillebimbim I added a simple filter... this should help you.
 
It throws a filterFilter is not defined. I'm using AngularJS to do this. I've looked into the $filter but that only seems to be used in the view and not the controller.
 
lin
12:17 PM
@krillebimbim inject filterFilter into your controller. Its a AngularJS core based filter provider.
 
Thanks. The filter works but the entire method is still not working. Apparently the rest api only returns a minimum number of tags and not all. The filter therefore rarely finds the information needed.
 
lin
Well ...
 
Hi lin! I think I finally figured it out
thansk for helping me out
I created a new api call to get all the categories with the per_page=100 parameter
 
lin
hi, cheers. it would be nice if you mark my answer as right... for all the helping :)
 
I will do it now ;)
 
lin
12:24 PM
year, also take a look at "hidden_tags" param
"hide_empty"
 
alright I'll have a look at that too
 
lin
Glad to help ya
 

last day (14 days later) »