New answers tagged

0

Since wordpress 4.5 you can add inline script by wp_add_inline_script(). To add a javascript snippet to the footer that requires jQuery, this code helps you function enqueue_jquery_in_footer( &$scripts ) { if ( ! is_admin() ) $scripts->add_data( 'jquery', 'group', 1 ); } add_action( 'wp_default_scripts', 'enqueue_jquery_in_footer' ); ...


0

Try This one : wp_register_script('cycleall', plugins_url('/assets/scripts/jquery.cycle.all.js', __FILE__), array('jquery'),'1.1', true); wp_enqueue_script('cycleall'); change script to scripts in add_action() should be add_action ('wp_enqueue_scripts', 'theme_add_cycle_slide' );


0

Problem was a simple misspelling. The add_action should be add_action ('wp_enqueue_scripts', 'theme_add_cycle_slide' ); I wrote 'script'


0

It's jQuery not JQuery. Try jQuery('div').raty({ score: 3 });


0

How does your function pw_load_scripts() know about the existence of $dataToBePassed? Is the variable global? Looking at the code you've got, I'm guessing that, as far as wp_localize_script() is concerned, $dataToBePassed is a local variable, and it's probably null.


0

Just change both lines: wp_register_script( 'wildstyle', plugins_url('css/wildstyle.css', __FILE__ ) ); wp_enqueue_script( 'wildstyle' ); to wp_register_style( 'wildstyle', plugins_url('css/wildstyle.css', __FILE__ ) ); wp_enqueue_style( 'wildstyle' );


2

You can add stylesheet in back-office, but you need for that use the admin_enqueue_scripts action. See Codex reference : https://codex.wordpress.org/Plugin_API/Action_Reference/admin_enqueue_scripts


0

You should enqueue scripts like this: function this_is_my_shortcode(){ add_action('wp_enqueue_scripts', function() { wp_register_script('per-pas-belanja-online', plugins_url('js/per-pas-belanja-online.js', __FILE__), array('jquery'), '1.0.0'); wp_enqueue_script('per-pas-belanja-online'); }); return '<div id="poppedout">Blah&...


1

That isn't how functions.php works in WordPress. The functions.php in your theme root directory is loaded into WordPress environment by default as long as your theme is activated. It's used as a plugin to add features and functionality of your theme to WordPress. You should take a look at theme functions and including css & javascript for more info. ...


0

Kinda just answering this to counter the "not-possible" answers... Yes it is probably not the best thing to do, since we are still unsure what the OP is trying to achieve, but that does not make it not possible... complex and impractical perhaps, but still entirely possible. First enqueue the script as you normally would... here setting the minimum and/or ...


0

As @Mark Kaplan correctly points out, the right answer to this clear question is No. What you can do, and maybe asking on Stackoverflow will get a better answer, is run scripts in response to certain browser sizes and also detect when the window is resized if that is also important to you. This isn't without its problems, but these are JS issues, not WP ...


3

No it isn't. Server can not know browser width. Not sure it is even a smart idea since the width of the browser can change at any point.


0

The enqueue_parent_theme_style() and my_jquery_enqueue() functions do not have closing brackets. Does the above code run? Otherwise the code looks okay. Are running WordPress with WP_DEBUG set to true? https://codex.wordpress.org/Debugging_in_WordPress I use the following in my wp-config.php file: if ($_SERVER['REMOTE_ADDR'] == '123.456.789.123') { ...


1

You have wp_enqueue_script( 'showMake' ); twice. Remove the last line from your sdm_load_javascript_files function and see if it works.



Top 50 recent answers are included