• 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

What short code do I use for the current year?

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 › What short code do I use for the current year?

This topic is: resolved

Tagged: short code, shortcode, year

  • This topic has 3 replies, 2 voices, and was last updated 8 years, 9 months ago by nutsandbolts.
Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • August 29, 2014 at 6:52 am #121666
    Neeznoodle
    Member

    Hello,

    I am using the Mocha theme want to add short code to some of my posts that displays the current year, so that the year will automatically update on January 1st of the next year.

    I know that there is the footer short code of [footer_copyright], but that also shows the copyright symbol. What short code can I use that is just the current year?

    Thank you

    http://fortheloveofharry.com/harry-potter-costume/
    August 29, 2014 at 7:27 am #121672
    nutsandbolts
    Member

    You can use the following in functions.php to create such a shortcode:

    //* Add shortcode for the current year
    function year_shortcode() {
    	$year = date('Y');
    	return $year;
    }
    
    add_shortcode('year', 'year_shortcode');

    You should then be able to use [year] in your posts to output the date.


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

    August 29, 2014 at 7:38 am #121677
    Neeznoodle
    Member

    Perfect! Thank you.

    August 29, 2014 at 7:39 am #121678
    nutsandbolts
    Member

    You're welcome! 🙂


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

  • Author
    Posts
Viewing 4 posts - 1 through 4 (of 4 total)
  • The topic ‘What short code do I use for the current year?’ is closed to new replies.

CTA

Ready to get started? Create a site or shop for themes.

Create a site with WP EngineShop for Themes

Footer

StudioPress

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