Tag Info

New answers tagged

1

Shortcodes are inconvenient for such things, because they are processed in content, way after site's header. However since you don't need to deal with styles, only a script, it's a little easier by moving stuff to footer. Your logic would be something like following: Locale shortcode stores requested locale in some way. At some point between content and ...


0

function theme_name_scripts() { wp_enqueue_style( 'style- name', get_stylesheet_uri() ); wp_enqueue_script( 'script- name', get_template_directory_uri () . '/js/example.js', array(), '1.0.0', true ); } add_action( 'wp_enqueue_scripts', 'theme_name_scripts' ); add to tour function php.


2

I would use jquery-masonry included in Wordpress core: function my_scripts() { wp_enqueue_script( 'jquery-masonry', true ); } add_action( 'wp_enqueue_scripts', 'my_scripts' ); If you really need the standalone masonry library, you should use your "first way" but I would not use "my_masonry" as handle for the script, I would use "masonry" if you have ...


0

Lead dev of Redux here. If you declare global $redux_global in your header.php file, it will be accessible by all other template files within your theme. You can also use $GLOBALS['redux_global']['css-block'] to bypass the need for $global $redux_global.


0

Thanks for posting your link. I'm sorry to say, but the theme you bought is no good, and you should really contact the author for a refund. Your scripts are loaded in the <body> tag, and some scripts even load before the jquery library. It is no use to even try and salvage the theme. You will end up mad. Here is a screenshot of the html Original ...


0

You don't have to manually handle dependencies. That is the whole point of the enqueue system, it handles dependencies for you. There's nothing wrong with the code in your post, so if you want help on it, you'll need to ask about your problem more specifically.


2

Scripts and stylesheets should always be loaded in the head or in the footer via the wp_enqueue_scripts action hook. wp_enqueue_scripts is the proper hook to use when enqueuing items that are meant to appear on the front end The init hook executes before wp_head which is to early for script to load in the header. The wp_enqueue_scripts action hook is ...


2

You should first load your scripts with a hook on wp_enqueue_scripts like this for example : add_action( 'wp_enqueue_scripts', 'load_my_scripts' ); function load_my_scripts() { wp_enqueue_script( 'jquery' ); } What I like to do is, register my script with a hook on init and then enqueue them with a hook on wp_enqueue_scripts: // Register Scripts ...


0

I did some checking in the dropbox.js code (v2) to see what was happening and how to best solve this. As it turns out, the data-app-key is only used to set the variable Dropbox.appKey. I able to set the variable with the following extra line. Using the javascript example on the Dropbox page https://www.dropbox.com/developers/dropins/chooser/js: ...


3

When you pour some water into a glass, first you put the glass on the table, then you turn the bottle. If you first turn the bottle, and then put glass on the table, your floor gets wet and your glass stay empty. Actually wp_enqueue_scripts is just a way to save a variable (water) inside a global object (glass), so before to call the function (turn the ...


2

It is required, actually. There's no real difference between themes and plugins as such. Neither of them should take actions on merely being loaded, they should use action hooks on functions to have things happen in the correct ordering.


0

This solution is similar to @scribu's answer, but it follows the form of wp_enquque_script(), and will place the script in the header if its dependencies are included in the header. /** * Enqueue inline Javascript. @see wp_enqueue_script(). * * KNOWN BUG: Inline scripts cannot be enqueued before * any inline scripts it depends on, (unless they are * ...


1

Do you have the "all-in-one-wp-security-and-firewall" plugin? More info: https://wordpress.org/support/topic/load-scriptphp-fails-to-load?replies=3 Short answer, if so, disable the "Deny Bad Query Strings" option. If not, check for any other "security" plugins you have that might be doing dumb things.



Top 50 recent answers are included