Closed Marneus77 closed 6 years ago
@Marneus77 You can pull a list of posts like this. Not ideal but it works.
client.Posts.GetAll().Result.Where(x => x.Slug.ToLower() == the_slug)
Ok thanks. I thought maybe with custom query? A GetBySlug would be nice also (like GetById). It will have to do.
We should have this as an option in the query builder. Getting everything from the server first is too expensive.
For this purpose, it was necessary to create a lot of methods. Such as GetWithInclude, getWithExclude, GetByTags, GetBySearch and so on. We decided that this is not practical and provided you with the opportunity to create a query yourself using QueryBuilder. For your purposes, the following code is suitable.
var PostsQuery = new PostsQueryBuilder(){
Slugs=new string[] { "the_slug1","the_slug2"}
};
var result = await client.Posts.Query(PostsQuery);
Thank you, it's working
Which method allows me to get a post, category or page using slug instead of id? I can't find a way. e.g. /wp/v2/POSTS?slug=the_slug