Posted By

vagrantradio on 12/22/10


Tagged

wordpress


Versions (?)

Load Contact Form 7 only when needed


 / Published in: PHP
 

Prevents WordPress from loading Contact Form 7 on page templates other than the one defined.

  1. add_action ('wp_print_scripts', 'my_deregister_cform', 100);
  2.  
  3. function my_deregister_cform() {
  4.  
  5. if (!is_page_template('page-contact.php')) {
  6.  
  7. wp_deregister_script('contact-form-7');
  8.  
  9. }
  10.  
  11. }

Report this snippet  

You need to login to post a comment.