I don’t think it will work – the whole idea of having two different template tags is to make them behave differently. See http://codex.wordpress.org/Template_Tags
Date and time tags
Thread Starter
Lumina
(@lumina)
Hrmmm…and you’re meaning that vice-versa as well? As in not only can you not force the occurence of the_time down, but there’s also absolutely no way on earth to call the_date more than once?
Another question – I was looking through the tags and noticed that example three on the_date says something about assigning the date to the $my_date
variable. What’s that, and how can I work with it?
Correct, the_date is meant to only be called once. That’s why when it’s called for the 2nd post on a particular day, nothing outputs.
You’d need a plugin to do what you are looking for.
Since the_date()
can be configured to display the time, and the_time()
likewise with the date, I’d look hard at the format parameter on both tags to see how to alter date and/or time formatting based on how you wish to implement them.
RE: $my_date
: The example is just showing anyone who might need to use the date of a post in their PHP scripting how to pull it from the_date()
.
Hey, I had the exact same problem. Here’s what I did… It’s an ugly, ugly hack but it seems to work. I copied the_date function and then cut out the If statement at the top that prevented you from using the date more than once. Then, I copied this into an “extradate.php” file and included it at the top “require(‘extradate.php’);”.
<?php
function extra_date($d=”, $before=”, $after=”, $echo = true) {
global $id, $post, $day, $previousday, $newday;
$the_date = ”;
if ( $d==” )
$the_date .= mysql2date(get_settings(‘date_format’), $post->post_date);
else
$the_date .= mysql2date($d, $post->post_date);
$the_date .= $after;
$previousday = $day;
$the_date = apply_filters(‘the_date’, $the_date, $d, $before, $after);
if ( $echo )
echo $the_date;
else
return $the_date;
}
?>
now i can call extra_date(); as much as I please.