Multiple endpoints in one URL

Not sure of the context for this, is it a custom post type or just a page? This might be something which you’re looking for – function add_lead_management_endpoints() { add_rewrite_rule( ‘manage-lead/lead_id/([0-9]{1,})/product_id/([0-9]{1,})’, ‘index.php?pagename=manage-lead&lead_id=$matches[1]&product_id=$matches[2]’, ‘top’ ); add_rewrite_tag( ‘%lead_id%’, ‘([^&]+)’ ); add_rewrite_tag( ‘%product_id%’, ‘([^&]+)’ ); } add_action( ‘init’, ‘add_lead_management_endpoints’ ); You’ll need to flush permalinks for this to … Read more

Add rewrite endpoint to author page + pagination

Your code should works. The line: include (get_template_directory_uri() . ‘/articles.php’); Needs to have allow_url_include=1 in the server configration because you are trying to include a file via http. Can you check this? You must know also that template_redirect should be use for a real redirect, a include() may have undesired effects here. I think what … Read more

WordPress 4.7 REST API endpoints

According to ticket #38373 the following endpoints will be supported in version 4.7. Let me quote Rachel Baker: REST API endpoints for your WordPress content. These endpoints provide machine-readable external access to your WordPress site with a clear, standards-driven interface, allowing new and innovative apps for interacting with your site. These endpoints support all of … Read more

Widget with random posts from a blog for external sites

To create a special output of random posts: Register an endpoint to the root of your blog. See A (Mostly) Complete Guide to the WordPress Rewrite API for details. Refresh the permalink settings. I would do this on (de)activation only. Hook into ‘template_redirect’ and return your output depending on the details of the requested endpoint. … Read more

How can I get users email (and additional data) from the rest API?

To add the user’s email address in the REST API response, register an additional field to the user object and add the email address: register_rest_field( ‘user’, ‘user_email’, [ ‘get_callback’ => static function (array $user): string { return get_userdata($user[‘id’])->user_email; }, ] ); Please note, however, that this is strongly discouraged because anyone can then see the … Read more