• 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

Adding a custom shortcode to the Genesis Post Info

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 › Adding a custom shortcode to the Genesis Post Info

This topic is: not resolved

Tagged: entry-meta, genesis, modified date, post-date, shortcode

  • This topic has 2 replies, 2 voices, and was last updated 11 years, 4 months ago by Stefsull.
Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • February 14, 2014 at 4:06 pm #90365
    Stefsull
    Member

    I've googled and tried several things. Nothing is working so I'm gonna need help from one of you wizards. My designer wants the post meta to contain:

    Category | Modified date | Comments/No Comments

    I took the easy way out and used Genesis Simple Edits to make it happen, and it ALMOST worked — meaning, it worked as long as I wanted to use the date the post was created on, not the date it was modified on.

    I created a custom shortcode for the modified date (in my functions.php file):

    // Add custom shortcode for [post_modified_date]
    function modified_func( $atts ){
    	return the_modified_date();
    }
    add_shortcode( 'post_modified_date', 'modified_func' );

    However, I can't make that work in the Simple Edits plugin (that I can find anyway). My shortcode works, but it renders outside the .entry-meta instead of inside it where the [post_date] did (and where I put it in the Simple Edits plugin).

    So I'm sure I need to move the whole kit and kaboodle into my functions.php and out of Simple Edits. My problem is syntax. I can get this far:

    // Show modified date instead of created date
    remove_action( 'genesis_entry_header', 'genesis_post_info', 12 );
    add_action( 'genesis_entry_header', 'custom_post_info' );
    function custom_post_info() {
    }

    But nothing I do INSIDE those pretty little brackets renders what I want. I'd rather not have to redo that whole entry-meta area, but I reckon that since I'm customizing it already, I'm going to have to. If I do have to write a function to replace the whole entry-meta, how do I intersperse the shortcodes with the actual HTML (so that the shortcodes don't render AS HTML text?

    What I have is this:

    <p class="entry-meta"><span class="entry-categories">Topic: <a href="http://support.contatta.com/category/general/" title="View all posts in General" rel="category tag">General</a></span> | Modified on: <time class="entry-time" itemprop="datePublished" datetime="2013-10-02T22:38:40+00:00">October 2, 2013</time> <span class="entry-comments-link"><a href="http://support.contatta.com/how-do-i-invite-a-new-user-to-contatta/#respond">No Comments</a></span></p>

    What I want is something like:

    <p class="entry-meta"> [post_categories sep=", " before="Topic: "] | Modified on: [post_modified_date] [post_comments zero="No Comments" one="1 Comment" more="% Comments"] </p>

    Can someone point me in the right direction? (And I DO want to keep my modified-date in the <time tag for the markup.)

    Cheers

    http://support.contatta.com
    February 15, 2014 at 1:03 am #90445
    Tom
    Participant

    Hi Stefsull,
    This works. You'll have to tweak to setup the html and order the elements you want. First take out your shortcode and deactivate Simple Edits.

    From Chris Lema: ... we find a comment from Brad Dalton that gets us to the code snippet we want from Greg Rickaby. Brad maintains this in a Gist here: https://gist.github.com/braddalton/6445390

    Hope this is what you're looking for.


    Choose your next site design from over 350 Genesis themes.
    [ Follow me: Twitter ] [ Follow Themes: Twitter ] [ My Favourite Webhost ]

    February 15, 2014 at 6:29 pm #90549
    Stefsull
    Member

    Thank you SO much, Tom. That totally sent me down the right path... in case anyone else wants to do something similar, I'll paste my final code here:

    //* Use modified date instead of published date 
    remove_action( 'genesis_entry_header', 'genesis_post_info', 12  );
    add_action( 'genesis_entry_header', 'modified_post_info' );
    
    function modified_post_info() {
    	if ( is_page() || is_search() )
    		return; // don't do post-info on pages ?>
            
    	<div class="entry-header entry-meta">
    	<span class="entry-categories">Topic: <?php echo the_category( $separator =', ' ) ; ?></span> | 
    	<span class="date published time">Modified on: <time class="entry-date" itemprop="startDate" datetime="<?php echo the_modified_date( 'c' ); ?>" pubdate><?php echo the_modified_date(); ?></time></span> | 
    	<span class="entry-meta-comments"><a href="<?php the_permalink() ?>#comments"><?php comments_number( 'Leave a Comment', '1 Comment', '% Comments' ); ?></a></span>
    	</div>
            <?php }

    Again, thanks!

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