Howdy I am new to WordPress and I am attempting to create an ajax endpoint that outputs JSON so I can entry it via jQuery Datatables. I am utilizing Air Mild theme for my present web site and what occurs after I go into /wp-admin/admin-ajax.php?motion=ajax_endpoint
is that it simply provides me 0. I attempted querying posts, customers, and my customized tables all of them give me 0 although I’ve a standing code 200.
I am questioning if there’s one thing unsuitable I am doing right here. I’ve additionally tried placing an echo someplace within the perform and it doesn’t present up.
features.php
namespace Air_Light;
/**
* The present model of the theme.
*/
outline( 'AIR_LIGHT_VERSION', '8.3.2' );
/**
* Theme setup code
*/
add_action('wp_ajax_ajax_endpoint', 'ajax_endpoint');
add_action('wp_ajax_no_priv_ajax_endpoint', 'ajax_endpoint');
perform ajax_endpoint(){
international $wpdb;
$outcomes = $wpdb->get_results('SELECT * FROM desk');
echo json_encode($outcomes);
wp_die();
}