Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Show Titles on Archive pages and Blog page
<?php
//* Show titles on genesis archive pages - including blog page - is_home()
add_action ( 'genesis_before_loop', 'twpg_show_archive_title' );
function twpg_show_archive_title() {
if (is_category()) {
echo '<h1 class="entry-title">' . single_term_title('Articles in category: <span>', false) . '</span></h1>'; //Display Category or Tag title
} elseif (is_tag()) {
echo '<h1 class="entry-title">' . single_term_title('Articles tagged with: <span>', false) . '</span></h1>'; //Display Category or Tag title
} elseif (is_author()) {
$post_id = get_queried_object_id();
$post_author_id = get_post_field( 'post_author', $post_id );
$author_display_name = get_the_author_meta('display_name', $post_author_id);
echo '<h1 class="entry-title">' . __('Articles written by: ') . '<span><a href="'.get_the_author_meta('user_url', $post_author_id).'" alt="'.__('Visit website for ').$author_display_name.'" title="'.__('Visit website for ').$author_display_name.'" target="_blank">'. $author_display_name . '</a></span></h1>';
} elseif (is_home()) {
echo '<h1 class="entry-title">' . get_the_title(get_queried_object_id()) . '</h1>';
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment