Here’s an updated version of your code that removes any prefix:

php

<?php $archive_title = get_the_archive_title(); $prefixes_to_remove = array('Category: ', 'Tag: '); // Add more prefixes if needed // Remove prefixes $trimmed_title = str_replace($prefixes_to_remove, '', $archive_title); echo '<h1 class="page-title">' . $trimmed_title . '</h1>'; the_archive_description( '<div class="archive-description">', '</div>' ); ?>

In this version, you can easily add more prefixes to the $prefixes_to_remove array if needed. The str_replace function will then remove any of the specified prefixes from the archive title.

Replace your existing code with this modification in your archives.php file.

Leave a Reply

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