1

I have a multisite wordpress installation on aws linux, working perfectly fine. The WP Rest api is also working exactly as it should. Except for one single case.

/wp-json/wp/v2/posts?author=<some int>

For everything else, including my custom endpoints, and custom params/fields added to the api, it works perfectly. But the moment i add the author part, it returns 404 on all sites. eg:

/wp-json/wp/v2/posts?author_exclude=1     //this works
/wp-json/wp/v2/posts?page=2               // this also works
/wp-json/wp/v2/posts?page=2&author=abc    // this also works and returns invalid author
/wp-json/wp/v2/posts?page=2&author=1      // this returns 404 page not found

From some of the other similar questions, I found that this issue could be due to permalinks, but I am using custom permalinks

sitename/%year%/%monthnum%/%day%/%author%/%category%/%postname%/

I have tried changing the permalink to no effect. Another solution I found is to change all the deny to allow in htaccess. I am not well-versed in htaccess, so i have not modified it for fear of causing some security issues. As for other related info, I am also using jwt and disable rest api plugin(with only jwt endpoints enabled).

Any help would be appreciated, please.

  • A quick test on my local installation shows that your /wp-json/wp/v2/posts?author=<some int> endpoint should work just fine -- it'll return an array of posts, or an empty array [] if the author doesn't exist or has no posts. Have you tried turning off all your plugins to see if one of them is the culprit? – Pat J Aug 3 at 21:43
  • @PatJ Found the culprit, it was Wordfence. Sadly, Turning it off or switching to a different plugin is not an option. My only idea is to add an endpoint for this in my own plugin. Any other ideas would be most welcome. – Deepon GhoseRoy Aug 8 at 6:10
  • I'd open a ticket with Wordfence support, and see what they say. – Pat J Aug 8 at 13:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.