Created
September 16, 2019 09:10
-
-
Save Tiex84/b5b86bb58c21f88c4ce7d17cdc281ec4 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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