Show Today’s Date on a WordPress Page

If you are using WordPress to create squeeze pages or landing pages and want to create a page that always displays the current date, this tip is for you! By adding just a few lines of code to your functions.php file, you can create a WordPress shortcode that allows to you to insert a dynamic date anywhere on your page. For example, perhaps you have a sales letter page with the date displayed at the very top, and you want “today’s date” to automatically be updated without having to edit the page all the time … this video will show you how it’s done:

You need to upgrade your Flash Player to version 8 or newer.

Below is the code that you need to copy and paste into your functions.php file:

// [date]
function displaydate(){
return date('l, F jS, Y');
add_shortcode('date', 'displaydate');
// end date

To insert the dyanamic date anywhere on a WordPress page, simply add the following shortcode to your page:


Like this tip?

Would you like to receive the WordPress Tip of the Day delivered straight to your inbox each and every day?
Click here to subscribe now!

Comments (4)

Trackback URL | Comments RSS Feed

  1. Gary says:

    Ben, Is there a plugin or does your theme have an option to “show or hide” the date of a post?
    For example, if I had a category that I wanted to post content that may be evergreen and not “dated”
    I really enjoy your videos-

  2. Ben Cope says:

    When using the WordPress Dream Theme, if you want to hide the date on your posts, all you need to do is add the following code to your stylesheet:

    .postdate { display: none; }

  3. Matt says:

    I just got the follow error message when I did as the video suggested:

    Warning: Cannot modify header information – headers already sent by (output started at /home/matthewk/public_html/ in /home/matthewk/public_html/ on line 890

    Any ideas on how to fix this?

  4. Hi there,
    Thanks so much for posting this, it was exactly what I was looking for. I’m pretty new to CSS and appreciated the opportunity to learn how to add the date to my page.
    With infinite love & gratitude,

Post a Comment

If you want a picture to show with your comment, go get a Gravatar.