Show Current Date, Month, Year in WordPress With Shortcode

I had some articles where I had to show the current month and year. Now it’s an annoying job to manually update all those articles once the month ends.

So, I needed something that would update the month and year automatically.

Hence, I created a shortcode. Now, instead of putting the month, I would just put the shortcode.

As a result, once the month ends, shortcode will update it automatically.

Since I needed something like this, I thought there could be others who would need something like this. So, I made a plugin of it and submitted to the repository.

You can get the plugin here – Shortcode For Current Date

How To Show Current Date, Month, Year in WordPress

As the name suggests, you can show the current date, month or year with the shortcode.

Download and install the plugin and you’re ready to go.

After installing the plugin, in your post editor just put [current_date] where you want to show the date.

Here’s a demo. Today’s date is: 22nd March 2018

It’s as simple as that.

Now, to show the month or year you would have to add something to the shortcode.

Let’s say, You want to show the current month and year. To do that, you would need to write the shortcode like this:  [current_date format='F, Y']

Output of this shortcode will be the current month along with the year and that is March, 2018

Easy, right?

The shortcode basically uses the PHP date function to generate the date, month or year. That means, you can use any format the function accepts.

Check out the date formats and use the ones that suits your needs.

Just remember to use the ‘format’ attribution. Otherwise, your shortcode will not generate the date or month or year correctly.

If you have any questions or suggestions, don’t forget to use the comment box.

4 Replies to “Show Current Date, Month, Year in WordPress With Shortcode”

  1. I’m a little confused: I want to automatically put the date of publication into my posts/articles. Is that what your plug-in does, or does your plug-in constantly show the CURRENT date?

    For example, if I publish an article on January 3, 2018, and I use your plug-in with the code, then January 3, 2018 gets entered. So what happens further on down the line? If I go back to that page in March, is it then going to show the March date, which would then be current, or is always going to show the January 3, 2018 date – which is the date of publication?

    Thank you very much,


Leave a Reply

Your email address will not be published. Required fields are marked *