I am trying to create a shortcode to display a post’s date and category. I have cobbled this together and I can get the category to show properly but not the date. What am I doing wrong?
Here is a link to the sample page: http://testdoug.com/phr-test/test-post-1/
//[categories-list]
function insertcats( $atts, $content = null ) {
global $post;
$categories = get_the_category_list( ', ', '', $post->ID );
$my_date = get_the_date('echo $date_style;', FALSE);
return '<div class="vcex-blog-entry-date"' . $my_date . '<div class="blog-category">' . $categories . '</div></div>';
}
add_shortcode("insertcats", "insertcats");
your markup is a little wrong and you’re missing a closing tag.
the correct format should be: