admin管理员组文章数量:1426036
I have plugin I would like to use only on the contact page, however the script and css is being loaded on every page. Aside from the increased http requests, it is also causing another script to not work properly on another page.
Is there a way to stop this plugin from loading anywhere else on the site?
I know how to do this with normal scripts in the header, but I am not sure how to do this with a plugin that automatically injects scripts into the header.
Thanks in advance.
I have plugin I would like to use only on the contact page, however the script and css is being loaded on every page. Aside from the increased http requests, it is also causing another script to not work properly on another page.
Is there a way to stop this plugin from loading anywhere else on the site?
I know how to do this with normal scripts in the header, but I am not sure how to do this with a plugin that automatically injects scripts into the header.
Thanks in advance.
Share Improve this question asked Dec 24, 2012 at 12:39 AdamAdam 6555 gold badges11 silver badges19 bronze badges3 Answers
Reset to default 4I have figured it out.
There is a good explanation here
You edit the wp.config
file with the scripts you wish to not load...
define('WPCF7_LOAD_JS', false);
...and then manually enqueue them on the pages you wish to load the script.
Try using
if(is_page('contact-page-slug')){
to add your functions to that page only.
Try this CODE:
if ( ! is_page('THE NAME OF THE PAGE WHERE YOU WANT CF7 TO RUN') ) {
add_filter( 'wpcf7_load_js', '__return_false' );
add_filter( 'wpcf7_load_css', '__return_false' );
}
Source: From the official CF7 page.
本文标签: Load plugin on specific page only
版权声明:本文标题:Load plugin on specific page only 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745467250a2659586.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论