Enqueueing scripts and styles multiple CPTS

There is a built-in function that you can use, instead of globals. The get_current_screen() function allows you to get the information associated with the current page. One of its return values is post_type. So you can check against an array of post types to see if anyone matches. function fhaac_admin_enqueue_scripts(){ $screen = get_current_screen(); if ( … Read more

include ‘wp_enqueue_scripts’ (CSS) to multiple templates

Page template seems like a more obscure thing to base the loading of your CSS on. Maybe not use template name, and use page name instead as it’s more apparent to theme users. If interested you could try something more like this: add_action(‘wp_enqueue_scripts’, ‘load_special_page_styles’); function load_special_page_styles() { global $post; if( is_page() ) { switch( $post->post_name … Read more

How to add Bootstrap Tour JavaScript to WordPress Admin Panel Dashboard Widget

Step-1 → Download: Download the necessary CSS / JS files for Bootstrap Tour in your theme’s directory. Step-2 → Tour setup script: Follow the instructions from bootstraptour for the Tour setup script. For example, the following script will load the Tour on the main WordPress Admin Panel Dashboard (on page load) and show the tour … Read more

admin_enqueue_scripts not working

If you remove that conditional in the first line of the enqueue function, your scripts should load. I can’t see the broader context of why your function is written that way, but if you just copied it from a tutorial or something, you don’t need it here. Try: <?php function sunset_load_admin_scripts(){ wp_enqueue_media(); wp_register_script(‘sunset-admin-script’,get_template_directory_uri() .’/js/news_admin.js’, array(‘jquery’), … Read more

Exclude JS file from 404 error page

There is is_404(). I normally use it to do just the opposite, to add CSS and JS animations which are specific to the 404 error page. In your case that would be: function wpse_339946() { if ( ! is_404() ) { wp_enqueue_script( ‘tracking-js’, get_template_directory_uri() . ‘/js/tracking.js’ ); } } add_action( ‘wp_enqueue_scripts’, ‘wpse_339946’ );

wp_localize_script not working on ajax response

Please try below code : script.js jQuery(function($) { var i; for(i=1;i<21;i++){ $(‘body’).on(‘change’, ‘#file’+i, function() { var file_data = $(this).prop(‘files’)[0]; var id = $(this).attr(‘id’); var form_data = new FormData(); form_data.append(‘file’, file_data); form_data.append(‘action’, ‘file_upload’); jQuery.ajax({ url: pw_script_vars.ajax_url, type: ‘POST’, contentType: false, processData: false, data: form_data, success: function (response) { alert( response.alert ); } }); }); } }); … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)