<?php the_time(); ?> is a tag related to posts, and is meant for use inside The Loop.
I suspect it works in the default theme (and others) because the sidebar is included in the template after The Loop has run (that is, towards the end of the template). So it’s cheating by using the post_date from the last post, which is still accessable to <?php the_time(); ?>.
What you’re probably looking for is wp_title.
“What you’re probably looking for is wp_title.”
?
“?”
Sounds a bit weird but as he’s looking for You are currently browsing the weblog archives for <?php the_time('F, Y'); ?>., wp_title should suffice.
From Codex:
# Page title always includes the blog name.
# If viewing a post, it includes the title of the post.
# If viewing an archive page, it includes the year and month for the archive.
# If viewing a category, it includes the category name.
ifelse, I’m aware what wp_title() does. The ? was because I’m pretty sure melbell’s problem is displaying the current archive month and year when on an archive page, not the month and year *and* blog title.
Unless melbell can live with that.
If he wraps it in a is_archive() conditional, it should display only on an archive page (i.e. only the month and year or category name) without the blog title.
i.e.
if (is_archive()) { ?>
You are currently browsing the weblog archives
for <?php wp_title(''); ?>.
I sense a patch request to a certain included theme being worked out…
I will try the wp_title thing. My sidebar is at the beginning of this theme, so if it being at the end is what makes it work, then that makes sense.
Ok, I added <?php wp_title(''); ?> and it works pretty well…but now it says “You are currently browsing the archives for 2005 March.”
I want it to say “March 2005” and not “2005 March”. I know that if I used <?php wp_title('', FALSE); ?> it will return the result for use in PHP instead of printing it…I could them manipulate it to make it look how I want it to, but is that the only way? That’s an awful lot of trouble to go to if there’s an easier way.
Ok, here’s what I came up with…and it works! It displays “March, 2005”
<?php
$wholedate = (trim(wp_title('', FALSE)));
$dateArray = (explode(" ", $wholedate));
$date = ($dateArray[2] . ", " . $dateArray[0]);
echo $date;
?>
Now, does anyone know why I have to use $dateArray[2] instead of $datearray [1]? print_r comes up with 0=>2005, 1=> ,2=>March
It’s no big deal, I’m just wondering why that ” ” is in there for $dateArray[1]