• Forgiveness to all if I’ve not looked deeply enough, but this is rather strange. I’m looking here and not seeing what I’m supposed to. I could be out of my mind, though. . .

    I have a plugin which will filter the title of a post, but what I’m finding is that I’ve had to put in two filters, the_title for the title as it appears within the page and single_post_title for the title as it appears within the HTML <title> tags.

    Is there another, more convenient way to do it? I need this to happen on display as a filter, not on database save, as the page will change based on user input (its a user profile page plugin).

    Thanks in advance!!

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter Tom Belknap

    (@dragonflyeye)

    w00t! Worse than I thought: the filters I’m using are converting all page and post titles on the page, when they’re only supposed to change the current one. Anybody have any ideas?

    You can check if the title you’re filtering belongs to the current post by comparing it to the global $post->post_title variable.

    Here is an example filter

    function my_title_filter($title)
    {
    	global $post;
    	if( $title == $post->post_title ){
    		$title = 'My New Filtered Title';
    	}
    	return $title;
    }
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Filtering Titles?’ is closed to new replies.