Skip to content

Instantly share code, notes, and snippets.

@Tiex84
Created September 16, 2019 09:10
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 Tiex84/b5b86bb58c21f88c4ce7d17cdc281ec4 to your computer and use it in GitHub Desktop.
Save Tiex84/b5b86bb58c21f88c4ce7d17cdc281ec4 to your computer and use it in GitHub Desktop.
function hap_hide_the_archive_title( $title ) {
// Skip if the site isn't LTR, this is visual, not functional.
// Should try to work out an elegant solution that works for both directions.
if ( is_rtl() ) {
return $title;
}
// Split the title into parts so we can wrap them with spans.
$title_parts = explode( ': ', $title, 2 );
// Glue it back together again.
if ( ! empty( $title_parts[1] ) ) {
$title = wp_kses(
$title_parts[1],
array(
'span' => array(
'class' => array(),
),
)
);
$title = '<span class="screen-reader-text">' . esc_html( $title_parts[0] ) . ': </span>' . $title;
}
return $title;
}
add_filter( 'get_the_archive_title', 'hap_hide_the_archive_title' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment