Skip to content

Instantly share code, notes, and snippets.

@PurpleHippoDesign
Last active September 3, 2018 15:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save PurpleHippoDesign/8f07ebf29651d3360e69d2c2b4176a5b to your computer and use it in GitHub Desktop.
Save PurpleHippoDesign/8f07ebf29651d3360e69d2c2b4176a5b to your computer and use it in GitHub Desktop.
Remove archive title prefix from WordPress archive title
<?php //<~ Remove me
/**
* Remove archive title prefixes.
*
* @param string $title The archive title from get_the_archive_title();
* @return string The cleaned title.
*/
function ph_custom_archive_title( $title ) {
// Remove any HTML, words, digits, and spaces before the title.
return preg_replace( '#^[\w\d\s]+:\s*#', '', strip_tags( $title ) );
}
add_filter( 'get_the_archive_title', 'ph_custom_archive_title' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment