I've adjusted the Settings to load bootstrap but I only need the multiple bootstrap files that load on 2 pages of my site, so I'd like to only load it on those pages. How can I do this?
Thanks,
Tim
Thanks, I followed that post and adjusted the code slightly but it doesn't seem to be working. Bootstrap is still loading sitewide.
Here's the code I am using:
function dequeue_bootstrap_except_necessary(){
// a comma-separated list of post type slugs where you want to include Bootstrap
$cpts = array( 'realtor', 'realtors', 'testing' ); if ( !in_array( get_post_type() , $cpts) && !is_admin() ) {
// dequeue Bootstrap CSS
function dequeue_bootstrap_css(){
wp_dequeue_style( 'toolset_bootstrap_4' );
wp_dequeue_style( 'toolset_bootstrap_styles' );
}
add_action( 'wp_print_styles', 'dequeue_bootstrap_css' );
// dequeue Bootstrap JS
function dequeue_bootstrap_js(){
wp_dequeue_script( 'toolset_bootstrap_4' );
wp_dequeue_script( 'toolset_bootstrap' );
}
add_action( 'wp_print_scripts', 'dequeue_bootstrap_js');
}
}
add_action( 'wp_enqueue_scripts', 'dequeue_bootstrap_except_necessary', 100 );
Hi there,
To debug the code I would first check if it is possible to dequeue the CSS and JS files site wide without the if clause.
If yes, then I would have if clause with && operators instead of having the post type slugs added as an array.
If the issue persists, I'd appreciate it if you could give me the URL/User/Pass of your WordPress dashboard after you make sure that you have a backup of your website.
It is absolutely important that you give us a guarantee that you have a backup so if something happens you will have a point of restore.
Make sure you set the next reply as private.
I can take a look into that, please tell me where you added the custom code?