Add PHP Shortcode for current date?

Quattroporte

Regular Member
Joined
Nov 18, 2012
Messages
469
Reaction score
170
How can I add a shortcode that displays the current date?

I want something like "Working as of Wednesday, August 14, 2013". I know some code has to be entered in one the theme's files, but I'm not sure which one.

Any help is appreciated. :)
 
Code:
function date_wp
( $atts ){  
   return date('d/m/Y h:i:s'); 
} 
add_shortcode( 'foobar', 'date_wp' );
How can I add a shortcode that displays the current date?

I want something like "Working as of Wednesday, August 14, 2013". I know some code has to be entered in one the theme's files, but I'm not sure which one.

Any help is appreciated. :)
 
Code:
function date_wp
( $atts ){  
   return date('d/m/Y h:i:s'); 
} 
add_shortcode( 'foobar', 'date_wp' );

Which theme file would I add this too? And I take it I'd just have to add [date_wp] to my WP posts and it would work?
 
Add it to functions.php
call [foobar] (or rename it to something more interesting)
Which theme file would I add this too? And I take it I'd just have to add [date_wp] to my WP posts and it would work?
 
Back
Top