Skip to content

Instantly share code, notes, and snippets.

@cassler
Created February 7, 2014 04:07
Show Gist options
  • Save cassler/8857248 to your computer and use it in GitHub Desktop.
Save cassler/8857248 to your computer and use it in GitHub Desktop.
Show the proper H1 based on context
<?php function den_page_title() {
$post = $posts[0]; // Hack. Set $post so that the_date() works.
/* If this is a category archive */
if (is_category()) {
echo '<h1>Archive for the &#8216;' . single_cat_title() . '&#8217; Category</h1>';
} elseif( is_tag() ) { // If is tag archive
echo '<h1>Posts Tagged &#8216;' . single_tag_title(); . '&#8217;</h1>';
/* If this is a daily archive */
} elseif (is_day()) {
echo '<h1>Archive for ' . the_time('F jS, Y'); '</h1>';
/* If this is a monthly archive */
} elseif (is_month()) {
echo '<h1>Archive for ' . the_time('F, Y'); '</h1>';
/* If this is a yearly archive */
} elseif (is_year()) {
echo '<h1>Archive for ' . the_time('Y'); '</h1>';
/* If this is an author archive */
} elseif (is_author()) {
echo '<h1>Author Archive</h1>'
/* If this is a paged archive */
} elseif (isset($_GET['paged']) && !empty($_GET['paged'])) {
echo '<h1>Blog Archives</h1>';
}
} ?>
@cassler
Copy link
Author

cassler commented Feb 7, 2014

This is primarily for your archive.php template but works on index.php too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment