Remove Plugin Depending on Page Template Used
-
Hey guys, I am going to keep this post short and easy to follow.
I currently have a couple plugins that I would like to remove from all pages that use a specific template I made. The template I made is basically a “blank” template that only shows the page contents and some very minimal styling. Because this template was design to be loaded inside of an iframe, I dont want certain plugins loading on my page twice (once on the main page and again inside the iFrame).
The template name is “Blank Template” (file name: template-blank.php)
So here is the script that I created to place in the functions.php file that works exactly as intended, except it’s not conditional, it removes this chat plugin from ALL pages:
function removeChat() {
wp_deregister_script( 'push2call_script_client' );
}
add_action( 'wp_print_scripts', 'removeChat', 100 );
Now, where I am running into problems is when I try to make it condition based on the template. Here is one of many attempts I’ve made:
function removeChat() {
wp_deregister_script( 'push2call_script_client' );
}
if ( is_page_template('template-blank.php') ) {
add_action( 'wp_print_scripts', 'removeChat', 100 );
}
Can anyone tell me what I am doing wrong? I cant for the life of me figure this out, and I am about to rip my hair out! :) Thanks guys!
-
You did not specify a blog address or reason for posting when you created this topic.
This support forum is for blogs hosted at WordPress.com. If your question is about a self-hosted WordPress blog then you’ll find help at the WordPress.org forums.
If you don’t understand the difference between WordPress.com and WordPress.org, you may find this information helpful.
If you forgot to include a link to your blog, you can reply and include it below. It’ll help people to answer your question.
This is an automated message.
-
Sorry, I should be over at the “.ORG”. I didnt realize there were two seperate support forums.
- The topic ‘Remove Plugin Depending on Page Template Used’ is closed to new replies.