• 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

Code for Today's Date

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 › Code for Today's Date

This topic is: not resolved

Tagged: today's date

  • This topic has 11 replies, 2 voices, and was last updated 11 years, 5 months ago by BP.
Viewing 12 posts - 1 through 12 (of 12 total)
  • Author
    Posts
  • May 17, 2014 at 11:53 am #105636
    BP
    Member

    Does anyone have the code to add "today's date" in the Header Right widget area in the Prose theme?


    Brad

    May 17, 2014 at 3:05 pm #105657
    nutsandbolts
    Member

    First, add the following to your custom functions (this allows you to use shortcodes in widget areas and sidebars):

    // Enable shortcodes in widgets
    add_filter('widget_text', 'do_shortcode');

    After that, add the following (also in custom functions) to create a shortcode that will display the date - props to @srikat:

    // Add today's date shortcode
    add_shortcode('todays_date', 'get_todays_date');
    function get_todays_date($atts) {
    	// return date('F j, Y');
    	return date_i18n( get_option( 'date_format' ) );
    }

    Then you can use [todays_date] in the Header Right widget area to display the shortcode.


    Andrea Whitmer, Owner/Developer, Nuts and Bolts Media
    I provide development and training services for designers • Find me on Twitter and Google+

    May 18, 2014 at 8:14 am #105726
    BP
    Member

    Thank you! NutsandBolts. That's cool.

    Can you please tell me how to align the date right and change its color.


    Brad

    May 18, 2014 at 8:18 am #105727
    nutsandbolts
    Member

    Can you post a link to your site? It's always easier to help if we can see what you see.


    Andrea Whitmer, Owner/Developer, Nuts and Bolts Media
    I provide development and training services for designers • Find me on Twitter and Google+

    May 18, 2014 at 8:21 am #105728
    BP
    Member

    http://www.solotopia.com/


    Brad

    May 18, 2014 at 8:28 am #105730
    nutsandbolts
    Member

    Is the date on there right now? If it is, I can't see it.


    Andrea Whitmer, Owner/Developer, Nuts and Bolts Media
    I provide development and training services for designers • Find me on Twitter and Google+

    May 18, 2014 at 8:43 am #105734
    BP
    Member

    No. I remove it because it didn't look good.


    Brad

    May 18, 2014 at 9:08 am #105737
    BP
    Member

    See it here: http://www.webscapeproductions.com/ Black font, center.


    Brad

    May 18, 2014 at 9:15 am #105741
    nutsandbolts
    Member

    Okay, here's what worked for me on a test site.

    In your text widget, assign a div class to the shortcode like this:

    <div class="thedate">[todays_date]</div>

    Then in your stylesheet, you can do this:

    .thedate {
    color: #fff;
    float: right;
    }

    See if that works for you and let me know. 🙂


    Andrea Whitmer, Owner/Developer, Nuts and Bolts Media
    I provide development and training services for designers • Find me on Twitter and Google+

    May 18, 2014 at 9:27 am #105743
    BP
    Member

    Works! But creates white space between header and nav bar in small mobile devices when testing here: http://www.studiopress.com/responsive/ Do you know how to prevent that?


    Brad

    May 18, 2014 at 9:38 am #105746
    nutsandbolts
    Member

    Hmm... Try giving .thedate a background color just like the header and see if that gets it. I think we'll probably have to do a little more than that, though, so if that doesn't work...

    (1) Assign a background color to #header .widget-area

    (2) On your 960px media query, change the padding on the header from this:

    @media only screen and (max-width: 960px)
    #header {
    padding: 10px 0;
    }

    to this:

    @media only screen and (max-width: 960px)
    #header {
    padding: 15px 0;
    }

    Andrea Whitmer, Owner/Developer, Nuts and Bolts Media
    I provide development and training services for designers • Find me on Twitter and Google+

    May 18, 2014 at 10:37 am #105752
    BP
    Member

    I really appreciate all your help, but this is getting too complicated. The date is not all that important, so I'm just going to put it in another widget (which your code enabled) or use the one that's available in the primary nav extras (and use Genesis Prose Extras plugin to switch their locations.)

    Thank you for your time and efforts.


    Brad

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