wp-admin/admin-ajax.php 400 (Bad Request) plugin

You’re only hooking your AJAX response inside wp_head(): function rp_add_header() { if (is_single() || is_page()) { // etc. add_action( ‘wp_ajax_ajax_action’, ‘ajax_action_stuff’ ); // ajax for logged in users add_action( ‘wp_ajax_nopriv_ajax_action’, ‘ajax_action_stuff’ ); // ajax for not logged in users } } add_action(‘wp_head’,’rp_add_header’,1); But wp_head doesn’t run on admin-ajax.php, so your callbacks will never be hooked. … Read more

Disabling drift plugin from homepage

You can see that the plugin embeds the Drift code by hooking wp_head: // Add the Drift Javascript add_action(‘wp_head’, ‘add_drift’); So all you need to do is remove_action( ‘wp_head’, ‘add_drift’ ); when you’re on the homepage, e.g. in an if (is_home()) or if (is_front_page()) block (they’re more or less equivalent here) in your theme, which … Read more

Add external javascript to post template

Add The following code (in your theme’s functions.php) will register your script, and set jQuery as a dependency. So when you enqueue it, jQuery will also be enqueued. function my_scripts_method() { // register your script location, dependencies and version wp_register_script(‘my_custom_script’, get_template_directory_uri() . ‘/js/custom_script.js’, array(‘jquery’), ‘1.0’ ); } add_action(‘wp_enqueue_scripts’, ‘my_scripts_method’); You can then enqueue your script … Read more