Change title of time-based archives

⚠️ Code snippets might not be compatible with the latest version of your theme. Always use a child theme to customize your theme, and test your code on a staging website before migrating to production.

You can search the user’s forum or ask the user community by opening a new thread in the Customizr theme forum. Before opening a new topic, you might want to follow the troubleshooting steps..

If you want to change the titles of daily,monthly or yearly archives, add this to your child theme’s functions.php and modify the archive titles to suit your needs.

add_filter('tc_time_archive_header_content','my_time_archive_header_content');
function my_time_archive_header_content($content) {

   if ( is_day() || is_month() || is_year() ) {
       $archive_type   = is_day() ? sprintf( __( 'My Daily Archives: %s' , 'customizr' ), '<span>' . get_the_date() . '</span>' ) : __( 'Archives' , 'customizr' );
       $archive_type   = is_month() ? sprintf( __( 'My Monthly Archives: %s' , 'customizr' ), '<span>' . get_the_date( _x( 'F Y' , 'monthly archives date format' , 'customizr' ) ) . '</span>' ) : $archive_type;
       $archive_type   = is_year() ? sprintf( __( 'My Yearly Archives: %s' , 'customizr' ), '<span>' . get_the_date( _x( 'Y' , 'yearly archives date format' , 'customizr' ) ) . '</span>' ) : $archive_type;
       $content        = sprintf('<h1 class="%1$s">%2$s</h1>',
           apply_filters( 'tc_archive_icon', 'format-icon' ), $archive_type
           );
    }
    return $content;
}

 

 

Leave a comment

Your email address will not be published. Required fields are marked *