最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

permalinks - wordpress api using rest_route for other pages

programmeradmin0浏览0评论

Ok, so I am using WordPress rest API to fetch the data using front-end. I am having the plain permalinks and unfortunately, I am not allowed to change the permalinks. So, for


I am using the route option:

/?rest_route=/wp/v2/posts

And this is working completely fine.

Now my question is if I want to access a page URL with query params :


How could I do that with rest_route? Thanks in advance.

Ok, so I am using WordPress rest API to fetch the data using front-end. I am having the plain permalinks and unfortunately, I am not allowed to change the permalinks. So, for

https://www.example

I am using the route option:

https://www.example/?rest_route=/wp/v2/posts

And this is working completely fine.

Now my question is if I want to access a page URL with query params :

https://www.example?cat=12

How could I do that with rest_route? Thanks in advance.

Share Improve this question edited May 21, 2020 at 12:00 new asked May 21, 2020 at 11:34 newnew 314 bronze badges
Add a comment  | 

2 Answers 2

Reset to default 2

Actually I was able to figure out with a little modification to Rank's answer:

https://www.example/?rest_route=/wp/v2/posts&categories=12

You have to add the parameters at the end, so it is defined which data should be affected. You add it after the 'post' to get all posts within the category with the id of 12.

https://www.example/wp-json/wp/v2/posts?categories=12

发布评论

评论列表(0)

  1. 暂无评论