Why my admin-ajax url returns 0 even after adding echo and die() at the end of function?
Avoid using ajax URLs like this when working with ajax calls. Using wp_localize_script is a good way to accomplish this. Let’s assume your js code is in the script.js file. You need to localize that file. function my_theme_enqueue_scripts() { wp_enqueue_script( ‘custom-jquery’, ‘https://code.jquery.com/jquery-3.5.1.min.js’, array(), ‘1.0’, true ); wp_enqueue_script( ‘ajax-script’, plugin_dir_url( __FILE__ ) . ‘js/script.js’, array( ‘jquery’ … Read more