New answers tagged

0

The WordPress plugin Wordfence(ver. 6.0.22) was causing this issue. To fix this, go to "Options" and uncheck "Hide WordPress Version".


0

If you're outputting the script in the footer, you can call wp_localize_script at any point after your script is enqueued but before the script is output on wp_footer priority 20. function wp_enqueue_woocommerce_style(){ wp_enqueue_script( 'chroma_js', get_template_directory_uri() . '/js/chroma.js', '', '1.1', ...


0

I'm used this code recently to get variable in header image path.Add this function to your functions.php: function img() { return get_template_directory_uri().'/assets/img/'; } and use this in your header.php like this: <img src="<?php echo img(); ?>my-image.jpg">


0

<?php // Register the script wp_register_script( 'some_handle', 'path/to/myscript.js' ); // Localize the script with new data $translation_array = array( 'some_string' => __( 'Some string to translate', 'plugin-domain' ), 'a_value' => '10' ); wp_localize_script( 'some_handle', 'object_name', $translation_array ); // Enqueued script with ...


1

I have not directly an answer to solve your issue as it (please take a look at the edit part I add), but this codesnippet (function) could maybe help you to solve the version issues for .js as well for .css files. /** * Remove query (output)string from .js / .css * Using filters */ function wpse215386_remove_script_version( $src ){ $parts = explode( ...


0

Don't you need to be using wp_enqueue_script instead of wp_register_script? What I get from the wp_enqueue_script codex page the correct way to add scripts dependant on jQuery is: <?php function my_scripts_method() { wp_enqueue_script( 'custom-script', get_stylesheet_directory_uri() . '/js/custom_script.js', array( 'jquery' ) ...



Top 50 recent answers are included