Articles of endpoints

Is there a better way of handling AJAX requests in WordPress?

I’m currently building a pretty straightforward plugin, but it relies quite extensively on AJAX requests. I’m using the standard admin-ajax endpoint for the requests, but I find that it seems to be massively inconsistent, sometimes the request (for the same data) will take a few hundred milliseconds and then sometimes take a couple of seconds. […]

How to add a rewrite endpoint to unattached media?

I’m trying to add an endpoint to unattached media items. This is what I hope to achieve: …where foo is the endpoint I’m trying to add. Here’s my code: add_action( ‘init’, function() { add_rewrite_endpoint( ‘foo’, EP_ATTACHMENT ); } ); add_action( ‘template_redirect’, function() { global $wp_query; if ( ! isset( $wp_query->query_vars[‘foo’] ) ) { return; […]

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

How can I get the email adress from the users by using the REST API? I’m authenticating with nonce, and it seems to be working since I can do POST requests and change stuff. Do I have to add something to make it return all the user info? This is my JS: (function($) { var […]

How can I use get header from within my plugin?

I’m writing a plugin to do some specific business logic – edit records for authenticated users, etc. Rather than having the overhead of a form processing plugin that uses stuff in template tags. I’ve created a rewrite do redirect like: /mylisting/909 ->/wp-content/themes/myplugin/edit.php?id=909 Which seems to make sense as I’m keeping the very specific logic to […]

Help writing custom function with rewrite endpoint that generates a page from dynamic content

I’m creating a WordPress plugin that will pull content from an API and display it dynamically on a WordPress blog like it’s native content. An example of this content would be company locations. I already have a short code that pulls the list of locations into the preferred page, but we also want to dynamically […]

add_rewrite_endpoint() and Custom Post Type Archive

I’ve got a custom post type. Let’s call it books. I’m adding a new rewrite endpoint called pages. I want the url /books/pages/2/ to work but I don’t see any rewrite rules generated by WordPress for this. I can manually add the rewrite rules for this specific example, but I’m looking for a way to […]

Rewrite Endpoints not Indexing with google

I don’t know if anyone else has found this, but I’ve created some Endpoints for Authors to now have several pages, but Google isn’t seeing any of them. It seems to see the parent url, but not any of the endpoints. Anyone had this issue or know if endpoints need something extra to be seen? […]

Enpoint Not Found in Rewrite Tag Permalink

I’m trying to make an XML feed show nice and pretty permalinks rather than showing query strings. The problem is I can’t get my /products/ endpoint to show up when trying to process my custom rewrite template tag. Here’s what I have: /** Register Query Vars **/ function theme_custom_query_vars( $vars ){ $vars[] = ‘custom_category’; $vars[] […]

My php header() function is not working

// Edit: I figured it out. Hours and hours of banging my head against a wall and it turns out all this needed was one simple line: ob_clean(); Somewhere in some included file there’s probably one line of whitespace that is screwing things up. ob_clean() will work for now. Thanks for the effort everyone who […]

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 […]