Enqueue Style Problem

Community Forums Forums Design Tips and Tricks Enqueue Style Problem

This topic is: resolved

This topic contains 2 replies, has 2 voices, and was last updated by  fortyfivecreative 1 year, 7 months ago.

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #34299

    fortyfivecreative
    Participant
    Post count: 10

    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

    #34709

    Gary Jones
    Moderator
    Post count: 693

    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.


    Changes in Genesis 2.1 – the ultimate guide to every single change in Genesis Framework 2.1, 2.1.1 and 2.1.2 (all 90 of them!) | @GaryJ

    #34713

    fortyfivecreative
    Participant
    Post count: 10

    Perfect, thanks Gary…

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.