4

Is there a standard route for getting all blog posts by specific author id? I can't find anything obvious. I tried this but I get a 404 error

http://localhost:8888/mysite/wp-json/wp/v2/posts?author=125
7
  • Is it a vanilla setup? Permalinks on? Can you access other rest endpoints? Seems to work for public WP sites I tested on.
    – birgire
    Feb 19, 2021 at 11:51
  • That URL looks correct to me too. Even if the author argument was incorrect, you should get a response with the all posts, not a 404. What are your permalink settings? Feb 19, 2021 at 12:22
  • 1
    So, I just deactivated all plugins and it works. I then activated one by one to find the culprit and it is WordFence. As soon as I activate that I get the 404 error again. I am not sure why this is but it is the plugin responsible. Feb 22, 2021 at 5:48
  • 2
    Seems like WordFence disables this route to prevent username fishing. There is an option to disable it and the author route works again Feb 22, 2021 at 5:58
  • 1
    For posterity, the setting in question is located at Wordfence > All Options > Brute Force Protection: "Prevent discovery of usernames through '/?author=N' scans, the oEmbed API, the WordPress REST API, and WordPress XML Sitemaps " - uncheck that box and you're golden Oct 18, 2022 at 6:27

1 Answer 1

2

So, I just deactivated all plugins and it works. I then activated one by one to find the culprit and it is WordFence. As soon as I activate that I get the 404 error again. I am not sure why this is but it is the plugin responsible.

Seems like WordFence disables this route to prevent username fishing. There is an option to disable it and the author route works again.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.