Change multiple words in title with a function
-
I want to change multiple words in wordpress titles. But i can only change 1 word.
How can i re-do this php script so it can change multiple words?For example word WORDPRESS & WORDPRESS2
Working but only changes 1 word.
function wpse_filter_post_titles( $title ) { return str_replace( 'WORDPRESS', 'REPLACETOTHIS', $title ); } add_filter( 'the_title', 'wpse_filter_post_titles' );I tried this 2 codes but it breaks whole site.
function wpse_filter_post_titles( $title ) { return str_replace( 'WORDPRESS', 'REPLACETOTHIS', $title ); return str_replace( 'WORDPRESS2', 'REPLACETOTHIS2', $title ); } add_filter( 'the_title', 'wpse_filter_post_titles' );function wpse_filter_post_titles( $title ) { return str_replace( 'WORDPRESS', 'REPLACETOTHIS', $title ) && return str_replace( 'WORDPRESS2', 'REPLACETOTHIS2', $title ); } add_filter( 'the_title', 'wpse_filter_post_titles' );
Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
The topic ‘Change multiple words in title with a function’ is closed to new replies.