Hi
I need to show both date and time for each post in the Query Loop Block, but I can only choose “Post Date” in the Dynamic Data section for Post Template.
I have tried to insert a shortcode instead. It shows the correct date and time I want, but it shows the same for all the posts!
My code looks like this:
function wf_post_date_time( $attributes )
{
$dateFormat = 'j. F Y \k\l. H:i';
$postId = null;
if(isset($attributes["date-format"]))
$dateFormat = $attributes["date-format"];
if(isset($attributes["post-id"]) && is_numeric($attributes["post-id"]))
$postId = $attributes["post-id"];
return get_the_date($dateFormat, $postId);
}
add_shortcode( 'post_date_time','wf_post_date_time' );
What am I doing wrong? Or are there a better solution to achieve this?
Thanks