• 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

Agency Theme – Need to add code to body tag

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 › General Discussion › Agency Theme – Need to add code to body tag

This topic is: not resolved

Tagged: body, Onload, Webervations

  • This topic has 5 replies, 4 voices, and was last updated 11 years, 9 months ago by leepettijohn.
Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • August 22, 2013 at 10:29 am #58220
    juliet
    Member

    Hello,

    I need to add this code to the <body> tag:

    onLoad="SetToToday('FirstSelect');"

    Any ideas?

    http://www.bearmountainbb.com/
    November 17, 2013 at 12:52 pm #73623
    cdils
    Participant

    Hi,

    You can hook into the <head> tag with wp_head().

    Carrie


    Have you been helped in this forum? Pay it forward and answer someone else’s question. I bet you’ll know the answer to at least one question. 🙂

    I host a weekly WordPress-focused podcast called Office Hours. I tweet @cdils.

    January 31, 2014 at 3:09 pm #87971
    leepettijohn
    Member

    Hi Juliet,
    Did you ever figure this out?

    Thanks

    February 1, 2014 at 10:40 am #88011
    songdogtech
    Participant

    @cdils, @juliet means in the <body> tag not in the <head> area.


    @leepettijohn
    , try this as an example in functions.php, and watch your single and double quotes:

    add_filter( 'body_class', 'my_body_class' );
    function my_body_class( $classes ) {
    $classes[] = ' onLoad=”SetToToday(‘FirstSelect’);” ';
    	return $classes;
    }

    Genesis may mangle the onload string, though.

    February 5, 2014 at 11:30 am #88787
    leepettijohn
    Member

    I GOT IT!!! YAY!!! Here's the solution I found. It's a little different and adds a variable to include the apostrophes before FirstSelect. Hope this helps everyone

    add_filter( 'body_class', 'my_body_class' );
    function my_body_class( $classes ) {
    	$fs = "'FirstSelect'";
    $classes[] = '" onLoad="SetToToday('.$fs.');" ';
    	return $classes;
    }
    February 5, 2014 at 11:43 am #88791
    leepettijohn
    Member

    OK, now I have another SNAFU. It works on the Crystal Theme but not the Agency-Pro theme. It turns the quotes into HTML code. Any ideas why?

  • Author
    Posts
Viewing 6 posts - 1 through 6 (of 6 total)
  • The forum ‘General Discussion’ 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

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