• 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

Injecting body class into Woocommerce product-archive

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 › Injecting body class into Woocommerce product-archive

This topic is: not resolved

Tagged: WooCommerce

  • This topic has 3 replies, 2 voices, and was last updated 6 years, 5 months ago by Victor Font.
Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • January 7, 2019 at 1:23 pm #225450
    deirdre
    Member

    I have this running for my main Genesis site by adding the following to page_archive.php:

    add_filter( 'body_class', 'genesis_header_body_classes' );

    But…I'm looking at the Genesis Connect archive-product.php and it's not clear to me where that would go.

    Main site is: https://baycon.org

    Shop page is: https://baycon.org/shop

    You can see the baycon-2019 isn't getting injected into the body on the latter.

    https://baycon.org/shop
    January 8, 2019 at 6:52 am #225473
    Victor Font
    Moderator

    You're not using a correct hook for adding a body class to Genesis. You should be using something like this:

    function vmf_my_custom_class( $attributes ) {
        $attributes['class'] = $attributes['class'] . ' my-custom-class';
    
        return $attributes;
    }
     
    add_filter( 'genesis_attr_body', 'vmf_my_custom_class' );

    Using the proper hook makes adding the class universal across all Genesis pages, including the templates used with Genesis connect. See this for more information. https://victorfont.com/genesis-framework-add-a-custom-css-class-to-elements/


    Regards,

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

    January 8, 2019 at 3:39 pm #226967
    deirdre
    Member

    Ahh, well that would explain why I was having trouble, thank you.

    Thing is, different pages have different body classes (because we have all our years in one WP instance, but we want the pages from prior years to have that year's look).

    Each one's body class is set up in the relevant WP entry, so I can't specify the specific class in code. It looks like your example's hard-coded to use 'my-custom-class' (if I'm reading it correctly), but I just want to inject the already-defined class.

    Would I just change that to 'body-class' or is it more complex than that?

    January 8, 2019 at 7:30 pm #228764
    Victor Font
    Moderator

    It’s sample code. Edit it any way you want.


    Regards,

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

  • Author
    Posts
Viewing 4 posts - 1 through 4 (of 4 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