Rewrite Endpoint Url without ? before endpoint
Ok, I got it, thanks for the point in the right direction guys! add_rewrite_rule(‘^members/([^/]*)/([^/]*)/?’, ‘^members/$matches[1]/?$matches[2]’, ‘top’);
Ok, I got it, thanks for the point in the right direction guys! add_rewrite_rule(‘^members/([^/]*)/([^/]*)/?’, ‘^members/$matches[1]/?$matches[2]’, ‘top’);
Ok, so it might have been working all along, and I just hadn’t flushed the rewrites! function my_dept_listing_init() { //Easy flush if (isset($_GET[‘flush’])) { flush_rewrite_rules(); } //endpoint onto which queries are made add_rewrite_endpoint( ‘individuals’, EP_PAGES ); //This filter acts as a controller, inject into content add_filter(‘the_content’, ‘my_dept_listing_content_ctrl’); } add_action(‘init’, ‘my_dept_listing_init’); function my_dept_listing_content_ctrl($content) { global $post; … Read more
I think the add_rewrite_rule is the correct route to go and I think what you have is correct also barring the Regex. Try substituting what you have currently for this => ^my-page\/([0-9]+)\/?. Full code below: function setup_filter_rewrites(){ add_rewrite_rule(‘^my-page\/([0-9]+)\/?’, ‘index.php?pagename=my-page&my_var=$matches[1]’, ‘top’); } add_action( ‘init’, ‘setup_filter_rewrites’ );
Multiple Permalink Patterns for one page
Here is an example of how to use Javascript to read posts from the WordPress API. //Pegasus = Theme name $.getJSON(‘https://visionquestdevelopment.com/wp-json/wp/v2/posts’, function(data){ //foreach post for (i = 0; i < data.length; i++) { //console.log(data[i]); var output=””; var dateT; var dateArr = []; //skip one of the posts with 404s on images if( ‘1555’== data[i].id ) … Read more
First of all, you registered the route “latest-post”, but the URL you used is “latest-posts”. Second: In your “get_latest_post” function, you use the variable $category, but it is set nowhere. Fix the function like this: function get_latest_post ( $params ){ if(isset($params[‘category’])){ $post = get_posts( array( ‘category’ => $params[‘category’], ‘posts_per_page’ => 1, ‘offset’ => 0 ) … Read more
Custom Rest API namespace and endpoints are responding with 404 & 503 errors
Debug info from request handler
From the wp_die() reference, $args (string|array|int) (Optional) Arguments to control behavior. If $args is an integer, then it is treated as the response code. ‘response‘ (int) The HTTP response code. Default 200 for Ajax requests, 500 otherwise. So your REST API endpoint returns the error 500 because that’s the default header status sent by the … Read more
I figured out it could be an Authorization problem, then I looked the WooCommerce webhook functions and fount where the delivery is executed: /wp-content/plugins/woocommerce/includes/class-wc-webhook.php I hard coded my Authorization header after line # 303 in the deliver() function: ‘headers’ => array( ‘Content-Type’ => ‘application/json’, ‘Authorization’ => ‘Basic bmNkaWgdrGFsOiNIb25kdXJhczIwMThTUFMh’, ), Now I need to calculate the … Read more