Removing the title Category

Aug 18, 2015 • 

Another problem solved by googling.

The problem arose due to a bigger site design issue. I want to have an easy way to upload resources to the site without having to create loads of new pages, and I started to realise that using the blog to do this would be the most straightforward way. In that case, I simply create a post, categorize it as a resource for students or teachers, (potentially within a certain sub-category), and WordPress would automatically put the link in the right place, make it searchable and allow it to be easily found from the appropriate Category page, which would be linked to from the home screen.

The problem came when I made the Category pages. The title of each page was Category: Student Resources and Category: Teacher Resources. Having the word category didn’t look right.

Anyway, I found the solution in the link above. Essentially I pasted this text into the end of the functions.php file in the editor:

add_filter( 'get_the_archive_title', function ($title) {
 if ( is_category() ) {
 $title = single_cat_title( '', false );
 } elseif ( is_tag() ) {
 $title = single_tag_title( '', false );
 } elseif ( is_author() ) {
 $title = '<span class="vcard">' . get_the_author() . '</span>' ;
 }
 return $title;
});

Now, I’ve no idea what all that means, but it works. I’d love to know how it works, but that’s for another day.