Excluding all pages which dont use the plugin with a function
-
Hi,
Everything is fine with your plugin. My question is only about to find a way to remove the css and script files on all the pages that dont use the lightbox. I know that I can exclude those pages listing them inside the settings or directly inside the page itself, which is fine if I only want to exclude the homepage or a landing page, but which is becoming a huge task if it’s about hundreds of pages.
Would it be possible to create a function like the one below, that I use very often for Contact Form 7 in order to remove the css and scripts files on the head of pages in which Contact Form is not used ?
Such a function could improve drastically the performances of all the website in a fistful of seconds.
add_action('wp_enqueue_scripts', 'load_wpcf7_scripts'); function load_wpcf7_scripts() { if ( is_page( array( 'contact', 'voyance-en-face-a-face', 'rendez-vous-voyance', 'question-voyance-gratuite' ) ) ) { if ( function_exists( 'wpcf7_enqueue_scripts' ) ) { wpcf7_enqueue_scripts(); } if ( function_exists( 'wpcf7_enqueue_styles' ) ) { wpcf7_enqueue_styles(); } } }
Best regards,
J.
- The topic ‘Excluding all pages which dont use the plugin with a function’ is closed to new replies.