5

i am using WP rest API v1 and everything is ok.

But now i want taste some WP rest API v2. the problem is, when i cal:

mysite.com/wp-json/wp/v2/posts

or:

mysite.com/wp-json/wp/v2/post

or

mysite.com/wp-json/wp/v2/posts/

or any thing else is related ti this path:

mysite.com/wp-json/wp/v2...

the result is:

[{"code":"json_no_route","message":"\u0647\u06cc\u0686 \u0645\u0633\u06cc\u0631 \u062a\u0637\u0628\u06cc\u0642 URL \u0648 \u0631\u0648\u0634 \u062f\u0631\u062e\u0648\u0627\u0633\u062a \u067e\u06cc\u062f\u0627 \u0634\u062f"}]

and i don't know what is the problem and the point is i want to use WP rest API v1 and v2, together, so disabling WP rest API v1 is not an option.

PS: I removed and add WP rest API v2 but nothing change.

  • Sorry to say but you have two options for the moment. Asking at the correct forum when issues arise with this specific (3rd party)plugin or at github or you wait till the update from WP to version 4.5 (which will be in early April 2016). Note: if I am incorrect, and you are not using that plugin, I will delete my comment! – Charles Mar 4 '16 at 15:07
  • oh thanks dear dear @Charles, i post my issue there. it was so nice of you to guide me . – mil Mar 4 '16 at 19:47
4

OK, i find my answer. Just ask it here and as dear Charles sayed, they answered me, so fast, the answer is:

By default, WP-API v1 takes priority over v2. If v1 is installed and activated, then v2 routes are inaccessible.

To mitigate this, you'll need to register either v1 or v2 to a different base than wp-json. Both have filters to make this more or less easily possible:

add_filter( 'rest_url_prefix', function() {
    return 'wp-api';
});

and because i am not a WordPress guy, so i don't know where should i add this lines so i get help from this blog and add the lines to the

function.php

of my them.

  • +1 That is great to hear, you got your answer/solution and posted it here so others also know how to solve that issue. Please don't forget to mark your answer as solved. (I believe for 'new' ppl it takes two days before able to do) – Charles Mar 4 '16 at 23:06

Your Answer

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

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