Support » Fixing WordPress » the_title filter only for post/page title

  • Hi There, Im using this filter/hook in my functions.php file:

    function format_title($title) {
    	$last_space_position = strrpos($title, ' ');
    	if (in_the_loop() && $last_space_pos > 0) {
    		$title1 = substr($title, 0, $last_space_pos);
    		$title2 = substr($title, $last_space_pos);
    		$title = "$title1<br />$title2";
    	}
    	return $title;
    }
    add_filter('the_title', 'format_title');

    What Im doing is to break the title into 2 lines, but I dont want this on titles within single.php, where I have the pagination functions previous_post_link and next_post_link

    How do I solve this ? Is there any conditional tag I can add to this ‘if’ ?

Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘the_title filter only for post/page title’ is closed to new replies.