There is a way to change the WordPress Archive title without change the themes original files. The main reason i think WordPress is fantastic is flexibility. Most of the WordPress Themes like Codeless Themes use this function “get_the_archive_title()” to show the category titles and other archive pages.
Sometimes you want to change the default “Category:” string to “Albums:” . There are two ways :
- Hardcoded with change the original theme files
- Using WordPress Filter and Child Theme
The first method is problematic because when you will try to update the theme the change can be lost. The best way is to use Child Theme and in the functions.php file of the Child Theme you can add the add_filter function. Check out how to configure a child theme: How to Install a Child Theme
add_filter( 'get_the_archive_title', function ( $title ) { if( is_category() ) { $title = 'Albums'; } return $title; });
In the example above you see that we have overwritten the get_the_archive_title. If that case we have change the title only for the category archive type.
If you want to change the title of the search page you can use the conditional into is_search().
The add_filter can be used for any other WordPress default functions.
Have a nice day!
0 Comments