How do I format my shortcode date?
-
Hello, I’ve got the code below working ok (I need to extract the date the post was posted to go inside the content of the post with a shortcode), but it’s displaying the clock time as well eg, 2014-02-01 01:24:27 I would like it to display it like, Feb 1 2014. Can anybody tell me how I get this please? This is the shortcode that goes in the Post [mm-insert-date]
Cheers
//shortcode function in Theme functions.php
function mm_insert_date_func($atts) {
// Insert the post date, with optional before and after strings.
// [mm-insert-date before='<h3>’ after='</h3>’]
global $post;
extract(shortcode_atts(array(‘before’ => ”, ‘after’ => ” ), $atts));$output = “{$before}{$post->post_date}{$after}”;
return $output;
}
add_shortcode(‘mm-insert-date’, ‘mm_insert_date_func’);Here’s a link to where you’ll see it in action
https://www.thewebsitedeveloper.co.nz/tempProject/nzca-wordpress/adverts-embedded-in-post-idea/
- The topic ‘How do I format my shortcode date?’ is closed to new replies.