Blog Post: Dynamic Year In WordPress

Red Deer & Blackfalds Web Design Writes:

Here’s a quick and easy article for all you WordPress Developers who need a refresher on how to add a Dynamic Year into the footer (or possibly into an arbitrary page) of your website! If you want to include a dynamic year on a specific post and/or page then you will want to download the Insert PHP plugin from WordPress to go along with this article.

  1. In PHP Templates Files
  2. You can simply use the code <?php echo date(“Y”); ?> to populate an area within a .php template file under “Appearance > Editor”

  3. In Posts/Pages
  4. The other option is to use the “Get Year” property and have it inside of an individual post and/or page. To do this you use the PHP shortcode from the plugin mentioned above so it will look like [insert_php]echo date(“Y”);[/insert_php], and will populate your individual post/page as seen right here: 2018

This particular function can also be used to grab more than the year. Let’s look at a few more examples below:

  • <?php echo date(“Y, m, D”); ?> – 2018, 01, Wed
  • <?php echo date(“d, M, Y”); ?> – 24, Jan, 2018
  • <?php echo date(“m, d, y”); ?> – 01, 24, 18

Joshua Neufeld

Owner at Red Anchor Studio
At Red Anchor Studio we are dedicated to building local business! We offer high quality developments at an affordable price, and we can work to get your business online at any budget.

Latest posts by Joshua Neufeld (see all)