Where Should i write the code for wordpress ajax voting?
Use REST API endpoint instead! Lets register an endpoint at /wp-json/tomjn/v1/test, that calls tomjn_rest_test() when you hit it: add_action( ‘rest_api_init’, function () { register_rest_route( ‘tomjn/v1’, ‘/test/’, array( ‘methods’ => ‘GET’, ‘callback’ => ‘tomjn_rest_test’ ) ); } ); Now lets add the tomjn_rest_test function: function tomjn_rest_test( $request ) { return “moomins”; } Now when we visit … Read more