Skip to content

The Date – WordPress Shortcode

Posted by Nathan Giesbrecht on April 22, 2012 in Snippets, Snippets, Wordpress Shortcodes

This WordPress shortcode will return the current date in November 28, 1981 format, unless otherwise specified in the ‘format’ attribute of the shortcode. The ‘format’ string will use the PHP date function specification. Add the following function to your WordPress theme’s functions.php file.

function ng_date_shortcode($atts, $content = null) {
return ($content) ? date($content) : date("F d, Y");
}
add_shortcode('curr_date', 'ng_date_shortcode');

To display the current date in a post or page, use the shortcode by inserting [curr_date] in the body of the content.

For expert users, you can use

[curr_date]PHP_DATE_FORMAT_STRING[curr_date]

Spread The Love, Share Our Article

  • Delicious
  • Digg
  • Newsvine
  • RSS
  • StumbleUpon
  • Technorati
  • Twitter

Related Posts

Comments

  1. Nathan Giesbrecht October 21, 2016

    test

Trackbacks

There are no trackbacks on this entry.

Add a Comment

Required

Required

Optional


framework-break