I was wondering... Maybe I don't get the point here, don't know. I think that the rewrite api is still usefull for creating beautiful frontend urls for regular users. But I'm not sure on adding a json endpoint via ep_masks (for example: https://make.wordpress.org/plugins/2012/06/07/rewrite-endpoints-api/).

Isn'it a thing already covered by the new rest api? Am I missing something?

And by the way... Time to create a 'rest-api' tag here in http://wordpress.stackexchange.com?

closed as primarily opinion-based by Mark Kaplun, TheDeadMedic, Howdy_McGee, EAMann Dec 31 '15 at 19:13

Many good questions generate some degree of opinion based on expert experience, but answers to this question will tend to be almost entirely based on opinions, rather than facts, references, or specific expertise. If this question can be reworded to fit the rules in the help center, please edit the question.

  • Close voting as opinion based, as the answer will most likely depend on the exact thing you want to do and you preference in building end points. – Mark Kaplun Dec 29 '15 at 10:55

I think you should stop using rewrite endpoints to handle JSON responses. Instead you can and you should use the REST API.

So, instead of this:

function makeplugins_add_json_endpoint() {
    add_rewrite_endpoint( 'json', EP_PERMALINK | EP_PAGES );
add_action( 'init', 'makeplugins_add_json_endpoint' );

And then handle the JSON response at your own, you can and you should do something like this:

add_action( 'rest_api_init', 'cyb_register_api_endpoints' );
function cyb_register_api_endpoints() {

    $namespace = 'myplugin/v1';

    register_rest_route( $namespace, '/myendpoint/', array(
        'methods' => 'GET',
        'callback' => 'cyb_myendpoint_callback',
    ) );


function cyb_myendpoint_callback() {

    //$response can be a Object, JSON, array
    $response = [];

    return new WP_REST_Response( $response );


In conclusion: a JSON endpoint should be handle now through REST API.

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