Tagged Questions

Links a script file to the generated page at the right time according to the script dependencies, if the script has not been already included and if all the dependencies have been registered. You could either link a script with a handle previously registered using the wp_register_script() function, ...

learn more… | top users | synonyms

3
votes
3answers
10k views

How to add a javascript snippet to the footer that requires jQuery

I know I can add a script file to the footer of wordpress that requires jquery using this code: <?php function my_scripts_method() { // register your script location, dependencies and version ...
1
vote
0answers
253 views

How to correctly make admin pages for custom tables which don't show in the menu? [closed]

I have to create a custom table to store data for a client because they want a very precise search capability. I already have this working with custom post types and using custom fields, but with 800+ ...
2
votes
1answer
744 views

Enqueuing Script in functions.php vs on the page

Does it matter if I enqueue a script on just the page I need it to be used? As opposed to functions.php? Or, what is the best practice? In this example I need a rotator just on the front page of my ...
6
votes
1answer
5k views

How to load Widget javascript + css files only if used?

I'd like to keep the javascript and css styles used by my widget inside their own files (and not add them to the theme). But i can't seem to get wordpress to add them when the widget is actually used ...
0
votes
1answer
1k views

How to Run a jQuery Script after a Javascript Script has Finished in WordPress

I've got javascript (a) and jQuery script (b). I need (b) to run after (a) has finished running. I need them to run sequentially. How do I do that? In wp_enqueue_script, I've made (b) dependent on ...
0
votes
1answer
1k views

TinyMCE in a div / textarea on frontend?

I have a post on my frontpage and I want to add the TinyMCE editor to it and could not make it work. I've tried these guides without any luck ...
0
votes
1answer
1k views

wp_enqueue_script() not working

I'm trying to add this social-network button: <a href="http://svejo.net/submit/?url=[your url]" data-url="[your url]" data-type="compact" id="svejo-button">Add in Svejo</a> ...
1
vote
2answers
550 views

Best way to include jQuery and fire with script at bottom of container

I'm going to be using a jQuery slider on my homepage only (not a WP plugin, but a third party). What I'd like to do is include jQuery, the plugin's jQuery script using a .js file, then include the ...
0
votes
3answers
1k views

wp_enqueue doesn't work

Some of you might know that I've been really struggling with trying to enqueue Javascript to my Wordpress theme and I just can't get it to work. I need to get this done somehow. I will keep this ...
0
votes
1answer
73 views

should i be checking for jquery before enqueing it in a plugin

At the start of a typical plugin which uses jquery I have something like the following wp_deregister_script('jquery'); wp_register_script('jquery', ...
1
vote
2answers
87 views

Same Conditionals Not Working on Two Different Hooks

Everyone! I am new to WP and trying to build a plugin. I have the following codes working properly: add_filter('the_content', 'say_hello'); function say_hello($content){ if(is_single() || ...
3
votes
2answers
628 views

jQuery in header or footer

From my reading it seems there is a good case for loading scripts like jquery and dependencies into the footer as a preference if possible; however 2 things confuse me which. Firstly the default for ...
0
votes
2answers
789 views

Script loaders vs wp_enqueue_script

My Wordpress theme has a lot of .js scripts running and it takes plenty of time to load them all one by one. I would love to use a script loader like HeadJS or yepnopejs to speed things up. But... ...
1
vote
1answer
1k views

Why is jquery-ui-core enqueueing in my footer instead of the header?

This is what I'm using to make sure that I have jquery-ui-core available: if (!is_admin()) add_action('wp_enqueue_scripts', 'zg_load_scripts'); function zg_load_scripts(){ ...
1
vote
1answer
786 views

Is there a way to list all the JavaScript scripts that are actually loaded by WordPress? Do we care?

This page on the Codex gives us a list of all the default scripts that ship with WP. But how do we know which ones are actually being used so we don't have to manually enqueue them? Or do we care, and ...
2
votes
1answer
2k views

wp_enqueue_script order - external vs inline js

I have a few scripts loading with my theme: // loading script.js <script type="text/javascript" src="script.js"></script> // doing something using script.js <script ...
1
vote
1answer
123 views

wp_enqueue_script & constants?

I'm enqueuing a script: wp_enqueue_script('my-script', MY_SCRIPTS."/my-script.js"); How to get MY_SCRIPTS const working in this context? I know this works: $template_dir = ...
0
votes
1answer
178 views

Enqueuing a script before anything else

I wondered if it was possible to change the order in which a script is enqueued. I ask this because I wish to include the HTML5 enabling script but it needs to be included before any styles. Is ...
1
vote
2answers
734 views

Modernizr check first, then move on to wp_register_script()/wp_enqueue_script

I've been playing with Modernizr in WordPress lately and here's something that i'm trying to achive. I'm adding an HTML5 input field in a custom options page, specifically: <input type="number" ...
10
votes
5answers
6k views

wp enqueue inline script due to dependancies

Is there a way to use wp_enqueue_script() for inline scripts? I'm doing this because my inline script depends on another script and i would like the flexibility of inserting it after it's loaded. ...
6
votes
3answers
2k views

Conditional wp_enqueue_script on a page

For efficiency we are trying to hook some JS scripts only a certain page template of a theme that is to hold a form: page-with-form.php On the theme functions.php we've defined a init_method as ...
2
votes
2answers
1k views

wp_enqueue_script vs. wp_register_script

Trying to do the right thing here, and tying myself in a knot! So, in my header.php before wp_admin, I have: wp_enqueue_script('commonfunctions', child_template_directory . ...
1
vote
1answer
377 views

enqueue the scripts

I have a template that has been hardcoded in the header and it needs to be Enqueued. I don't know what to do and the template provider is giving me the run around. JQueries won't work because of it. I ...
2
votes
1answer
2k views

Wordpress Enqueue for homepage only, functions.php, wp-framework

I'd like to replace my: if(is_home()) { wp_enqueue_script( 'homestuff', get_theme_part( THEME_JS . '/home.js' ), array( 'jquery' ), null, true ); wp_enqueue_script( ...
8
votes
3answers
5k views

How to enqueue scripts on custom post add/edit pages?

I'm trying to enqueue a JS script only when someone is adding or editing a custom post type I created called "recipes". Currently the script works ok when I do this: if (is_admin()){ ...
1
vote
1answer
273 views

Execute script only on certain admin pages

To solve this problem i've used this in my js file: var location = String(window.location); //only runs in post.php and post-new.php if(location.search('post.php') != -1 || ...
0
votes
1answer
683 views

What to include to use jQuery UI Auto Complete

I was looking at the scripts included with WP and dont see what I can include to use jQuery UI Auto Complete. What do I use? I tried including the whole jQuery UI from Google CDN and auto complete ...
27
votes
1answer
6k views

Where is the right place to register/enqueue scripts & styles

I am using WordPress 3.1.4 by now. I am confused with where (which hook) do I use: to register and/or enqueue scripts and styles on front- and back-ends? Questions: Which are right hooks to ...
1
vote
2answers
1k views

jQuery UI AutoComplete & wp_enqueue_script

I looked at the included scripts in WordPress (wp_enqueue_script) and didnt find what I should include to use jQuery UI Autocomplete I am using it in the admin area. Should I just include jQuery UI ...
2
votes
2answers
2k views

How to control what jQuery version to include, with wp_enqueue_script

I'm using a script that is based on jQuery, so I'm not enqueue-ing jQuery directly, but via passing it in the array of dependent scripts: ...
5
votes
7answers
5k views

wp_enqueue_script adding conditional statement not working

This is the code im using in my functions file: add_action('init', 'sort_out_jquery_pngfix_frontend'); function sort_out_jquery_pngfix_frontend() { global $wp_scripts; if(!is_admin()) { ...
22
votes
7answers
8k views

Conditionally Loading JavaScript/CSS for Shortcodes

I released a plugin that creates a shortcode and requires a JavaScript file and a CSS file to load on any page that contains that shortcode. I could just make the script/style load on all pages, but ...
4
votes
4answers
616 views

Why are admin scripts not printed

I am trying to enqueue/print scripts in the admin area. But they dont seem to appear. add_action('admin_init', function() { add_meta_box('portfolio-meta', 'Details', 'portfolio_metabox_details', ...
3
votes
3answers
136 views

Why does this line of code make photo albums appear?

In a theme I built from scratch I'm using the WP Photo Album Plus plugin. Per some books I've been using as guides, I need to include this code in the header in order to make comments work in a blog: ...
2
votes
1answer
183 views

Adding Scripts in the Admin Area

I'd like to enqueue scripts only for an admin page that I've created. There's an example of this here: ...
3
votes
2answers
743 views

Correct place to register and enqueue scripts

I'm queueing several scripts in my themes Functions.php: if ( ! function_exists('b99_init_scripts') ) : function b99_init_scripts(){ if ( !is_admin()){ ...
0
votes
3answers
1k views

Loading scripts & styles from a meta box callback function

Case: I got a set of classes that build form fields based on data from an input array. The class can build the following types of form fields: input (basic, hidden, password) textarea radio ...
4
votes
2answers
2k views

Using wp_enqueue_script on shortcode function handler

I have this code function this_is_my_shortcode(){ wp_register_script('per-pas-belanja-online', plugins_url('js/per-pas-belanja-online.js', __FILE__), array('jquery'), '1.0.0'); ...
1
vote
3answers
282 views

Adding a Javascript slideshow to the home page

I'm trying to add a Javascript slide show to my WordPress home page. In my theme folder I have a js folder and then in that I have jquery.cross-slide.min.js and jquery.min.js. This is what I have and ...
2
votes
2answers
162 views

Inserting JS snippet in the footer if there is no wp_footer?

I wrote a plugin which uses wp_enqueue_script() which will include the snippet in either the header or footer depending on the parameters you pass it. The in_footer parameter works great - if the ...
3
votes
2answers
2k views

How can I de-register ALL styles all at once? And same with Javascript?

How can I get all enqueued styles or scripts and then deregister them all at once?
1
vote
1answer
798 views

Enqueue Style for a page/pages only

it is causing problem because i did not do it before. I am trying to enqueue style or may be scripts depending on page. But it not working. Here is the code: add_action('init', 'my_enqueue_styles'); ...
2
votes
4answers
4k views

How wp_enqueue_script works?

I am trying to get scripts via wp_enqueue_script();. I have tried this in header but WordPress is not importing any script. I am using like this wp_enqueue_script('jquery'); ...
2
votes
4answers
3k views

Asynchronous Javascript Loaders

I'd like to take advantage of loading my scripts while the page is loading. ie. Yepnope, head.js etc... But I also want to be able to enqueue the script so other plugins don't try adding their own. ...
3
votes
3answers
2k views

Is this a bad implementation of wp_enqueue_script for conditional usage?

Conditionally Including scripts whether js or css in xhtml document head...has been a generally tricky affair, especially if you want to enqueue something, based on a shortcode or custom meta field or ...
1
vote
1answer
7k views

How to link external javascript files?

I am working on a custom Wordpress theme for my bosses website. I have everything working perfectly so far except for one thing... the external javascript files will not work. I followed the exact ...
0
votes
1answer
580 views

Yoast SEO breaking media upload

I have a very simple site that I've modified a very small amount. After installing the Yoast SEO plugin I found that it broke the in post media attach/upload. I'm about 80% sure it's related to Jquery ...
0
votes
1answer
104 views

custom fields cannt be seen with version 3.1

I had a Theme that worked OK with ver 2.7. Now that I upgraded to 3.1; I cannot see the "custom fields" in the posts(may be hidden??). Can someone help.Thanks
1
vote
2answers
5k views

wp_ajax() question.. not using wp_enqueue_script?

hey guys, weird situation... I'm trying to use wp_ajax() for the first time. I'm normally using a normal jQuery ajax request but in my current case I get a lot of bugs so I thought about trying ...
0
votes
2answers
583 views

Loading a newer version of jQuery within WordPress

I've read about the WP enqueue_script() function, but if I wanted to use a newer version of jQuery than what my WP installation is using, can I load it through this & WP will use the latest ...