Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save kimcoleman/1468a1cd8d7e543afd6a0235a240f310 to your computer and use it in GitHub Desktop.
Save kimcoleman/1468a1cd8d7e543afd6a0235a240f310 to your computer and use it in GitHub Desktop.
Remove the prefix if it is a category archive or post type archive.
<?php
/**
* Remove the prefix if it is a category archive or post type archive.
*
* You can add this recipe to your site by creating a custom plugin,
* adding the customization to a Memberlite child theme,
* or using the Code Snippets plugin available for free in the WordPress repository.
* Read this companion article for step-by-step directions on either method.
* https://memberlitetheme.com/create-a-plugin-for-customizations-to-your-memberlite-site/
*/
function memberlite_remove_prefix_from_the_archive_title( $prefix ) {
// Add any other post type archives or taxonomy labels to this array.
if ( in_array( $prefix, array( 'Archives:', 'Category:' ) ) ) {
$prefix = '';
}
return $prefix;
}
add_filter( 'get_the_archive_title_prefix', 'memberlite_remove_prefix_from_the_archive_title' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment