What is the most effecient way of enqueuing scripts based on the current plugins template?
What is the most effecient way of enqueuing scripts based on the current plugins template?
What is the most effecient way of enqueuing scripts based on the current plugins template?
You can use is_page_template(‘template.php’) and just replace template.php with your template name.
I’m not good at this, but it could be because Cufon is not included in WordPress? So, you are deregistrating a script that is not included.. http://codex.wordpress.org/Function_Reference/wp_enqueue_script#Default_scripts_included_with_WordPress
WordPress uses the jQuery Suggest plugin, which existed before Autocomplete was added to UI. You can enqueue ‘suggest’ to load it if it’ll work for your needs. Otherwise I think you’d have to build a custom jQuery UI download and then just extract the Autocomplete code, otherwise you’ll have two versions of things stepping on … Read more
The social network button you posted comes in two distinct parts. First, the button itself is defined by the anchor tag. <a href=”http://svejo.net/submit/?url=[your url]” data-url=”[your url]” data-type=”compact” id=”svejo-button”>Add in Svejo</a> Then, presumably the script replaced that button with an iframe or something similar so you don’t have to send your users elsewhere to get it … Read more
I do it this way and it works fine. Make sure you don’t have jQuery defined anywhere else on your site (like manually in the header), as some browsers don’t like that. /** * Load assets on initiation */ add_action(‘init’, ‘load_assets’); function load_assets(){ wp_enqueue_scripts(‘jquery’); }
The problem is that your first block of inline datepicker js is before jQuery and jQuery UI. When you use wp_enqueue_script your script tags will be output where your wp_head() action hook is located. Move your inline datepicer js below wp_head and your jQuery should work. You should also be using the no conflict wrapper … Read more
You don’t need to enqueue jQuery if you enqueue ThickBox already. See this answer for details. thickbox.css gets called, jquery.js also. thickbox.js doesn’t. Lots of missing details: When do you call the function? Is there markup in the HTML output of your page? A script element for ThickBox? If so, do you get a 404 … Read more
The answer is to use wp_register_style() and wp_enqueue_style() before I do wp_register_script() and wp_enqueue_script() so that I can use relative image paths to the CSS file. I then move the url() stuff from jQuery and into the CSS file with this relative path.
Shouldn’t you be enqueuing that in functions.php instead? function script_enqueueing() { wp_enqueue_script( ‘scripts’, get_stylesheet_directory_uri() . ‘/js/scripts.js’, array(‘jquery’) ); } add_action(‘wp_enqueue_scripts’, ‘script_enqueueing’); Edit to add: if calling directly in header.php, use get_template_directory_uri(); instead.