AJAX Implementation
First, enqueue your script correctly, in functions.php: function my_enqueue_scripts() { wp_enqueue_script(‘jquery’); } add_action(‘wp_enqueue_scripts’, ‘my_enqueue_scripts’); Then, Authenticated users only (see https://codex.wordpress.org/Plugin_API/Action_Reference/wp_ajax_nopriv_(action)) (can also be in functions.php): function fetchData(){ // Not needed anymore, as you manage the case through the `add_action` method // if ( ! is_user_logged_in() ) { // return; // } // this can be … Read more