Loading conditionally in a page and a custom post type?
-
Hello ,
I downloaded EDD and purchased a dozen addons that I love it. To improve performance due to the size of my website, I’m trying to conditionally load EDD assets as well as the addons assets in two places; in the ‘store’ page where I’m using the [downloads] edd shortcode, and also in the individual download custom post types themselves.
I’m using this code:
function sumobi_edd_remove_scripts() { if ( is_single() ) { wp_dequeue_style( 'edd-styles' ); wp_dequeue_script( 'edd-ajax' ); wp_dequeue_script( 'edd-screenshots-frontend' ); wp_dequeue_style( 'edd-css-frontend' ); wp_dequeue_script( 'jquery-prettyphoto' ); wp_dequeue_style( 'css-prettyphoto' ); wp_dequeue_script( 'edd_acp_frontend_js' ); wp_dequeue_style( 'edd_acp_frontend_css' ); wp_dequeue_script( 'edd_acp_bpopup' ); wp_dequeue_script( 'edd-free-downloads-modal' ); wp_dequeue_style( 'edd-free-downloads-modal' ); wp_dequeue_script( 'edd-free-downloads' ); wp_dequeue_style( 'edd-free-downloads' ); wp_dequeue_script( 'edd-free-downloads-mobile' ); } } add_action( 'wp_enqueue_scripts', 'sumobi_edd_remove_scripts' );
This code will enqueue the scripts on the store page but not the individual ‘download’ custom post types. Using instead,
if ( ! is_singular( 'download' ) || is_page('store') ) {
Will do the opposite, it will enqueue in the ‘download’ custom post type individual downloads but it doesn’t enqueue the scripts on the ‘store’ page listing all the downloads.
What would be the right conditional argument to make it enqueue in both downloading listing pages and the individual downloads themselves?
Warm Regards,
Matt
- The topic ‘Loading conditionally in a page and a custom post type?’ is closed to new replies.