• 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

How to add a class to post-meta?

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 › How to add a class to post-meta?

This topic is: resolved

Tagged: classes, post meta

  • This topic has 1 reply, 1 voice, and was last updated 9 years, 4 months ago by meredi.
Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • June 19, 2016 at 9:31 am #187844
    meredi
    Member

    My purchased child theme is set up in such a way that blog entry styles are used both on the entry pages and for entry promos on the homepage.

    I would like to style these differently — for instance, I'd like there to be a different separator for the "post-meta" section when it's shown on an entry on the homepage, than when it's shown on the entry page itself.

    I was hoping to do this by adding a different class to "post-meta" depending on whether I'm on an entry page or not.

    This is kind of where I'm at:

    add_filter( 'genesis_post_meta', 'darling_post_meta_filter' );
    function darling_post_meta_filter( $post_meta ) {
    
    	if ( is_singular( 'post' ) ) {
    		$post_meta = '[post_categories before="Featured in: "] [post_comments zero="0" one="1" more="%"]';
    		/* $post_meta['class'] .= 'my-custom-class'; */
    	} else {
    		$post_meta = '[post_categories before=""] [post_comments zero="0" one="1" more="%"]';
    	}
        return $post_meta;
    
    } 

    The commented section where I'm trying to add the class is NOT working. Does anyone have any suggestions? There are no unique enclosing parent classes on the homepage so I don't believe I can do this just with CSS.

    June 19, 2016 at 10:20 am #187846
    meredi
    Member

    Sigh, a kind person on another forum pointed out that each page actually does have a unique class, which I can use to style things differently. I was looking for this but didn't look in the "body" tag so didn't discover the "home" class, for instance. That saves me from updating functions.php and makes this purely a CSS fix.

    Sorry, I'd delete the post if I could but I can't!

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

© 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