• 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

Enqueue Style Problem

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 › Enqueue Style Problem

This topic is: resolved

Tagged: conditional, enqueue, error, style, validation

  • This topic has 2 replies, 2 voices, and was last updated 9 years, 10 months ago by fortyfivecreative.
Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • April 9, 2013 at 11:19 am #34299
    fortyfivecreative
    Member

    Hi, wondered if you can help. I use this to enqueue a stylesheet on the front page only, yet this is producing invalid markup when validated (although it does correctly bring the stylesheet in):

    //*Add FlexSlider scripts and styles to homepage */
    add_action('genesis_after_footer', 'script_flex');
    function script_flex() {
    if(is_front_page()) {
    wp_register_script( 'flex_js', CHILD_URL.'/js/jquery.flexslider.js');
    wp_register_style( 'flex_css', CHILD_URL.'/css/flexslider.css');
    wp_enqueue_script( 'flex_js' );
    wp_enqueue_style( 'flex_css' );
    }
    }

    PRODUCES:
    <link rel='stylesheet' id='flex_css-css' href='http://www.starcic.org/wp-content/themes/custom/css/flexslider.css?ver=3.5.1' type='text/css' media='all' />

    IN THE HEAD OF THE HTML.

    (http://validator.w3.org/check?verbose=1&uri=http%3A%2F%2Fwww.starcic.org%2F)

    Thanks in advance
    David

    April 11, 2013 at 5:44 am #34709
    Gary Jones
    Member

    Don't hook to genesis_after_footer. Hook to wp_enqueue_scripts instead. If you want to add it to the footer, then use the extra parameters when registering the script to add it to the footer.


    WordPress Engineer, and key contributor the Genesis Framework | @GaryJ

    April 11, 2013 at 5:48 am #34713
    fortyfivecreative
    Member

    Perfect, thanks Gary...

  • 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

© 2023 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