• Skip to main content
  • Skip to forum navigation

StudioPress

  • Shop for Themes
  • My StudioPress

Forum navigation

  • Home
  • General Genesis Discussions
  • StudioPress Themes
  • Genesis Blocks
    • Genesis Blocks
    • Genesis Custom Blocks
  • Retired Themes
  • FAQs
  • Forum Rules
  • Internationalization and Translations
  • Forum Bugs and Suggestions
  • Forum Log In

Are You Using The WordPress Block Editor?

Genesis now offers plugins that help you build better sites faster with the WordPress block editor (Gutenberg). Try the feature-rich free versions of each plugin for yourself!

Genesis Blocks Genesis Custom Blocks

Conditionally load is_singular or is_page?

Welcome!

These forums are for general discussion on WordPress and Genesis. Official support for StudioPress themes is offered exclusively at My StudioPress. Responses in this forum are not guaranteed. Please note that this forum will require a new username, separate from the one used for My.StudioPress.

Log In
Register Lost Password

Community Forums › Forums › Archived Forums › Design Tips and Tricks › Conditionally load is_singular or is_page?

This topic is: not resolved
  • This topic has 2 replies, 2 voices, and was last updated 9 years, 10 months ago by lvvvvvl.
Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • August 18, 2016 at 10:59 pm #191581
    lvvvvvl
    Participant

    Hello,

    I'm currently using a plugin (easy digital downloads) that adds 14 asset files to every posts of my Genesis blog even though those assets are only used in a handful of pages.

    Using the code below I'm trying to conditionally load it in both the 'download' custom post type (which applies to each individual download) and also the 'store' page (where I've pasted the EDD shortcode to display all the downloads.)

    function sumobi_edd_remove_scripts() {
            if ( ! is_singular( 'download' ) || is_page('store') ) {
    		wp_dequeue_style( 'edd-styles' );
    		wp_dequeue_script( 'edd-ajax' );
    }
    }
    add_action( 'wp_enqueue_scripts', 'sumobi_edd_remove_scripts' );

    I was initially having issues with the theme's style loading before the EDD style and messing things up, but I manage to fix that thanks to a tutorial by Victor Font to solve a similar Woocommerce issue http://victorfont.com/change-genesis-child-theme-style-sheet-load-order/

    My problem is that the above code works on the 'download' custom post type but it doesn't enqueue the scripts on the 'store' page. Alternative, if i try "if ( is_single()" it will enqueue the scripts on the store page but not the individual 'download' custom post type.

    What would be the right way of doing this?

    Thank you.

    August 19, 2016 at 6:12 am #191589
    Victor Font
    Moderator

    You are hooking into the wrong action to dequeue a scripts and styles. To dequeue a script:

    function sumobi_edd_remove_scripts() {
    	if ( !is_single('download') || is_page('store') ) {
    		wp_dequeue_style('edd-ajax');
    	}
    }
    add_action( 'wp_print_scripts', 'sumobi_edd_remove_scripts', 100 );

    To dequeue a style:

    function sumobi_edd_remove_styles() {
    	if ( !is_single('download') || is_page('store') ) {
    		wp_dequeue_style('edd-styles');
    	}
    }
    add_action('wp_print_styles', 'sumobi_edd_remove_styles', 100)

    Regards,

    Victor
    https://victorfont.com/
    Call us toll free: 844-VIC-FONT (842-3668)
    Have you requested your free website audit yet?

    August 19, 2016 at 7:15 am #191598
    lvvvvvl
    Participant

    Oh, that would make sense. Awesome, thanks Victor, I'll give it a try.

    While researching how to fix this I stumbled across this https://make.wordpress.org/core/2011/12/12/use-wp_enqueue_scripts-not-wp_print_styles-to-enqueue-scripts-and-styles-for-the-frontend/ and how they mentioned not to use wp_print and instead wp_queueu so it focused my research on the wrong direction I think.

  • Author
    Posts
Viewing 3 posts - 1 through 3 (of 3 total)
  • The forum ‘Design Tips and Tricks’ is closed to new topics and replies.

CTA

Ready to get started? Create a site or shop for themes.

Create a site with WP EngineShop for Themes

Footer

StudioPress

© 2026 WPEngine, Inc.

Products
  • Create a Site with WP Engine
  • Shop for Themes
  • Theme Features
  • Get Started
  • Showcase
Company
  • Brand Assets
  • Terms of Service
  • Accptable Usse Policy
  • Privacy Policy
  • Refund Policy
  • Contact Us
Community
  • Find Developers
  • Forums
  • Facebook Group
  • #GenesisWP
  • Showcase
Resources
  • StudioPress Blog
  • Help & Documentation
  • FAQs
  • Code Snippets
  • Affiliates
Connect
  • StudioPress Live
  • StudioPress FM
  • Facebook
  • Twitter
  • Dribbble