when i put this code before get_header() it load the script but when put after get_header() it does not work and i should tell you that i use this in plugin that i want to use it in frontend
add_action( 'wp_enqueue_scripts', 'my_enqueue' );
function my_enqueue($hook) {
wp_enqueue_script( 'ajax-script', plugins_url( '/my_query.js', __FILE__ ), array('jquery') );
// in JavaScript, object properties are accessed as ajax_object.ajax_url, ajax_object.we_value
wp_localize_script( 'ajax-script', 'ajax_object',
array( 'ajax_url' => admin_url( 'admin-ajax.php' ), 'we_value' => 1234 ) );
}
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire