Skip to content

Instantly share code, notes, and snippets.

@yousufansa
Created November 19, 2020 05:39
Show Gist options
  • Select an option

  • Save yousufansa/6da1663fc638afe15002f1781e6d8b7d to your computer and use it in GitHub Desktop.

Select an option

Save yousufansa/6da1663fc638afe15002f1781e6d8b7d to your computer and use it in GitHub Desktop.
Front - Change Post Archive Title
if( ! function_exists( 'front_child_get_the_archive_title' ) ) {
function front_child_get_the_archive_title() {
if ( is_category() ) {
$title = esc_html__( 'Category Archives - ', 'front' ) . '<span class="page-description text-primary font-weight-semi-bold">' . single_term_title( '', false ) . '</span>';
} elseif ( is_tag() ) {
$title = esc_html__( 'Tag Archives - ', 'front' ) . '<span class="page-description text-primary font-weight-semi-bold">' . single_term_title( '', false ) . '</span>';
} elseif ( is_author() ) {
$title = esc_html__( 'Author Archives - ', 'front' ) . '<span class="page-description text-primary font-weight-semi-bold">' . get_the_author_meta( 'display_name' ) . '</span>';
} elseif ( is_year() ) {
$title = esc_html__( 'Yearly Archives - ', 'front' ) . '<span class="page-description text-primary font-weight-semi-bold">' . get_the_date( _x( 'Y', 'yearly archives date format', 'front' ) ) . '</span>';
} elseif ( is_month() ) {
$title = esc_html__( 'Monthly Archives - ', 'front' ) . '<span class="page-description text-primary font-weight-semi-bold">' . get_the_date( _x( 'F Y', 'monthly archives date format', 'front' ) ) . '</span>';
} elseif ( is_day() ) {
$title = esc_html__( 'Daily Archives - ', 'front' ) . '<span class="page-description text-primary font-weight-semi-bold">' . get_the_date() . '</span>';
} elseif ( is_post_type_archive() ) {
$title = esc_html__( 'Post Type Archives - ', 'front' ) . '<span class="page-description text-primary font-weight-semi-bold">' . post_type_archive_title( '', false ) . '</span>';
} elseif ( is_tax() ) {
$tax = get_taxonomy( get_queried_object()->taxonomy );
/* translators: %s: Taxonomy singular name */
$title = sprintf( esc_html__( 'Archives - %s', 'front' ), '<span class="page-description text-primary font-weight-semi-bold">' . $tax->labels->singular_name . '</span>' );
} elseif ( is_search() ) {
$title = sprintf( esc_html__( 'Search results for - %s', 'front' ), '<span class="page-description text-primary font-weight-semi-bold">' . get_search_query() . '</span>' );
} else {
$title = esc_html__( 'Blog', 'front' );
}
return $title;
}
}
add_filter( 'get_the_archive_title', 'front_child_get_the_archive_title', 20 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment