Last active
August 29, 2015 14:03
-
-
Save sunriseweb/3cf08ec58465f6abd86a to your computer and use it in GitHub Desktop.
Show Titles on Archive pages and Blog page
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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