What’s a good way to unenqueue all scripts for a single template page?

I haven’t tried it, but this might do it: global $wp_scripts; if (is_a($wp_scripts, ‘WP_Scripts’)) { $wp_scripts->queue = array(); } Basically just resetting the scripts queue to blank. Should work, I think. You’d want this right at the top of your attachment template, probably. From an optimization perspective, it would be faster to use the is_attachment() … Read more

Generate featured images old posts

You can look into this post: http://ken.ph/first-image-of-wordpress-post-as-thumbnail/ Or if you’re comfortable with MySql try using this (obviously check it on local database first): INSERT into wp_postmeta (meta_value, meta_key, post_id) SELECT DISTINCT(ID), post_type , post_parent FROM wp_posts WHERE post_type=”attachment” AND post_parent !=0 AND post_status=”inherit”; UPDATE wp_postmeta set meta_key = ‘_thumbnail_id’ WHERE meta_key=’attachment’

How to Access Script Tags in Header

If done right there should be a callback hooked to wp_enqueue_scripts which has either wp_enqueue_script or both wp_register_script and wp_enqueue_script in it. Something like the following from the Codex: function themeslug_enqueue_script() { wp_enqueue_script( ‘my-js’, ‘filename.js’, false ); } add_action( ‘wp_enqueue_scripts’, ‘themeslug_enqueue_script’ ); You will need to find that callback function in your theme or in … Read more

Add script into front from my plugin

Use wp_enqueue_scripts and admin_enqueue_scripts actions to enqueue your scripts: // for front end add_action(‘wp_enqueue_scripts’, array(&$this, ‘load_my_scripts’)); // for back end add_action(‘admin_enqueue_scripts’, array(&$this, ‘load_my_scripts’)); Also pay attention that it is bad practice to load your scripts on all pages of the site. Load your script only if need be: // … function load_my_scripts() { if ( … Read more

why quotes shown in WordPress?

I am not sure about the extra quotes. The best way to include a java script file is with wp_enqueue_script() as indicated here in the codex. The safe and recommended method of adding JavaScript to a WordPress generated page and WordPress Theme or Plugin is by using wp_enqueue_script(). This function includes the script if it … Read more

Register scripts located in child theme?

I think that none the options you has posted actually works. You are only registering the script, you need to enqeue them. Also, you should use wp_enqueue_scripts() action hook instead of init(). function register_scripts() { wp_register_script( ‘newsletter’, get_stylesheet_directory_uri() . ‘/scripts/scripts.js’, array( ‘jquery-migrate’ ), null ); wp_enqeue(‘newsletter’); } add_action( ‘wp_enqueue_scripts’, ‘register_scripts’ );

php syntax : [ && ] between commands [closed]

I think its actually not allowed or discouraged in WP coding standards. Its is basically saying “If true go ahead”. It’s a short form of this: if ( did_action( ‘init’ ) ) { $scripts->add_inline_script( ‘lodash’, ‘window.lodash = _.noConflict();’ ); } You can also think of this as if it’s inside brackets of an if statement … Read more

How to load library scripts in admin from plugins in noConflict wrapper?

I’m NOT actually Answering the question, I’m putting here, how I got my solution without being on that course: First of all, I got the initial solution to the enqueue problem from WPSE answer. It’s working like a charm. But the problem of conflicting re-occurred when I tried embedding the Media Uploaded to a field … Read more