Same Conditionals Not Working on Two Different Hooks
init is too early for conditional tags, use template_redirect instead. have a look at the action reference to see the order they’re executed.
init is too early for conditional tags, use template_redirect instead. have a look at the action reference to see the order they’re executed.
Its likely that you’re not enqueing your CSS file to be used in the admin area, however you did not say. Anyway, this is what you can do… Place the following into your functions.php file: add_action( ‘admin_print_styles’, ‘my_admin_css’ ); add_action( ‘wp_enqueue_scripts’, ‘my_admin_css’ ); function my_admin_css(){ if( is_admin() ) { wp_enqueue_style( “media_upload”, get_bloginfo(‘template_directory’).”/css/custom_admin.css”, false, false, “all” … Read more
Add the following code in functions.php file of your theme that will remove default jquery ui core and will add your provided latest jquery ui core file from your theme. function my_scripts_method() { if(!is_admin()){ wp_deregister_script( ‘jquery-ui-core’ ); wp_enqueue_script(‘jquery-ui-core’, get_stylesheet_directory_uri().’/jquery.ui.core.min.js’, array(‘jquery’), ‘1.9.2’, 1 ); } } add_action(‘wp_enqueue_scripts’, ‘my_scripts_method’); Tell me if it works for you or … Read more
Just take a look at the Codex for all the default scripts and their slugs. The jQuery UI stuff is: Name Handle Dependencies jQuery UI Core jquery-ui-core jquery jQuery UI Widget jquery-ui-widget jquery jQuery UI Mouse jquery-ui-mouse jquery jQuery UI Accordion jquery-ui-accordion jquery jQuery UI Autocomplete jquery-ui-autocomplete jquery jQuery UI Slider jquery-ui-slider jquery jQuery UI … Read more
You can do it in two ways…. Solution One: <?php add_action( ‘wp_head’, ‘myscript’ ); function myscript(){ echo ‘<!–[if lt IE 9]><script src=”https://wordpress.stackexchange.com/questions/138051/your_js_file_path”></script><![endif]–>’; }; ?> Solution Two: <?php global $wp_scripts; wp_register_script( ‘jsFileIdentifier’, ‘YourJsFilePath’, array(), ‘3.6.2’ ); $wp_scripts->add_data( ‘jsFileIdentifier’, ‘conditional’, ‘lt IE 9’ ); ?>
You can hook into wp_enqueue_scripts very late, using the priority argument of add_action. For example: function hook_really_late() { echo ‘Should reasonably be last’; } add_action(‘wp_enqueue_scripts’,’hook_really_late’,PHP_INT_MAX); PHP_INT_MAX should be the highest number assignable as a priority. It is possible that some other code uses the same trick though. That is still probably what I’d recommend. If … Read more
You do not show how you hook your wp_enqueue_script() call. But the error message you get is pretty clear, use one of the following hooks: wp_enqueue_scripts admin_enqueue_scripts login_enqueue_scripts depending on the use case – see the notes at the wp_enqueue_script() codex page for additional information. For example do for correctly enqueuing on the frontend: function … Read more
In theory the code you wrote should work, in the practical application you are missing some good practices which it might impact on how your code is working, so it’s better run through a bit of troubleshooting to tick off everything from the checklist. By de-registering jquery you are taking away both the jQuery core … Read more
Query Monitor will show you what is loaded or you can print them directly. function print_wp_scripts_queue(){ $scripts = wp_scripts(); echo “<pre><h1>scripts</h1>”; print_r ( $scripts->queue ); echo “<h1>todo</h1>”; print_r ( $scripts->to_do ); echo “<h1>done</h1>”; print_r ( $scripts->done ); echo “<h1>registered</h1>”; print_r ( $scripts->registered ); echo “</pre>”; wp_die(); } add_action( ‘wp_head’, ‘print_wp_scripts_queue’, PHP_INT_MAX ); wp_deregister_script removes a … Read more
I you want the script be enqueued on page-index.php and page-contact-us.php, then you must check that that page templates are used but you are checking if they are not used. Chagne this: if ( !is_page_template(‘page-templates/page-index.php’) && !is_page_template(‘page-templates/page-contact-us.php’) ) { with: if ( is_page_template(‘page-templates/page-index.php’) || is_page_template(‘page-templates/page-contact-us.php’) ) { The first code reads like: if is NOT … Read more