Created
March 16, 2026 17:58
-
-
Save grayayer/1dfa56478225466156b234567fd9f393 to your computer and use it in GitHub Desktop.
Add paragraph break after colon in post titles on wordpress single post pages.
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
| /** | |
| * Add paragraph break after colon in post titles on single post pages. | |
| * | |
| * @param string $title The post title. | |
| * @return string Modified title with paragraph break after colon if applicable. | |
| */ | |
| function modify_post_title_with_colon( $title ) { | |
| // Only modify title on single post pages. | |
| if ( is_single() && in_the_loop() && is_main_query() ) { | |
| // Replace colon with colon + paragraph break. | |
| return str_replace( ':', ':<br>', $title ); | |
| } | |
| return $title; | |
| } | |
| add_filter( 'the_title', 'modify_post_title_with_colon' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment