variable endpoints for webservice

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

How to use endpoint, but remove/rewrite endpoint base?

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’ );

How to get custom or filtered endpoints in WordPress API?

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

Get The latest post from a category

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

Need to forward Data from WooCommerce Webhook sent to same site WordPress REST API custom endpoint

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

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)