Can I define multiple callback methods depending on the call method?

He is my current custom API: add_action( ‘rest_api_init’, function () { register_rest_route(‘my-project/v1/form’, ‘/get’, array( ‘methods’ => WP_REST_Server::READABLE, ‘callback’ => ‘get_form’ )); }); add_action( ‘rest_api_init’, function () { register_rest_route(‘my-project/v1/form’, ‘/post’, array( ‘methods’ => ‘POST’, ‘callback’ => ‘post_form’ )); }); Here is something I would like to write, but I’m not sure if it is possible. What … Read more

How to have multiple rewrite endpoints in the same URL?

I’d like to add multiple query_var / value pairs to any URL. For example the base URL of a page is: example.com/nice-page/ I can already achieve one endpoint like (for example, an on-page subgallery): example.com/nice-page/my-gallery/animals/cats Where my-gallery is the query_var and animals/cats is its value. Using this: add_rewrite_endpoint(‘my-gallery’, EP_PAGES); add_rewrite_endpoint(‘my-lightbox’, EP_PAGES); I also need this … Read more

rewrite endpoint not working on home page

I’m using this code to create a rewrite endpoint in a custom plugin: function setup_seo_endpoing() { add_rewrite_endpoint( ‘item’, EP_ALL ); } add_action( ‘init’, ‘setup_seo_endpoint’); This code is running / getting called, and the endpoint works with one problem: If I visit the home page (let’s say http://example.com), it is in fact displaying the correct static … Read more

Add rewrite rule for rewrite endpoint

I’ve created an rewrite endpoint with the add_rewrite_endpoint function … here is the whole contruct: // Register to query vars add_filter( ‘query_vars’, ‘add_query_vars’); function add_query_vars( $vars ) { $vars[] = ‘account’; return $vars; } // Add rewrite endpoint add_action( ‘init’, ‘account_page_endpoint’ ); function account_page_endpoint() { add_rewrite_endpoint( ‘account’, EP_ROOT ); } // Account template add_action( ‘template_include’, … Read more

Add extra parameters after permalink?

How can I add extra parameters after a permalink, specifically if I’m using a custom post type? For example, let’s say http://mysite/album/record-name was the permalink. How can I make http://mysite/album/record-name/related not turn up a 404 or redirect? WordPress doesn’t seem to call up the post template if the post doesn’t exist… so I’m at a … Read more

register_rest_field for custom taxonomy fields that are assosiated with custom post type

I am trying to register a rest field for my custom taxonomy’s custom meta fields. I followed the tutorial at Modifying Responses . The code worked great for adding a rest field for post meta data for custom post types, but when I tried the following code to add a rest field for my custom … Read more