Home Forums Support h-Tags

Viewing 5 posts - 16 through 20 (of 20 total)
  • Author
    Posts
  • #135364
    Tom
    Lead Developer
    Lead Developer

    Just tested the code above again – it’s definitely removing my page titles.

    Can you confirm that you’re checking your static pages and not blog posts?

    #135368
    Alexander

    Not at me, not on Static Pages and not on Blog Posts 🙁

    I make some Tests, if i do this:

    
    add_filter( 'the_title', 'generate_remove_page_titles', 10, 2 );
    function generate_remove_page_titles( $title, $id = null )
    {
    	global $post, $generate_content_filter_completed;
    
    	if ( $generate_content_filter_completed ) {
    		//return $title;
    	}
    
    	if ( is_page() && in_the_loop() && $title == $post->post_title )
    		return '';
    
    	return $title;
    }
    

    The Title go away on Static Pages, but not on Blog Posts!?

    #135374
    Tom
    Lead Developer
    Lead Developer

    Try this for pages and single posts:

    add_filter( 'the_title', 'generate_remove_page_titles', 10, 2 );
    function generate_remove_page_titles( $title, $id = null )
    {
    	global $post, $generate_content_filter_completed;
    
    	if ( $generate_content_filter_completed ) {
    		//return $title;
    	}
    
    	if ( ( is_page() || is_single() ) && in_the_loop() && $title == $post->post_title )
    		return '';
    
    	return $title;
    }
    #135394
    Alexander

    This works on both!
    But why is it so complicated with me?

    So i can remove this Part:

    
    	if ( $generate_content_filter_completed ) {
    		//return $title;
    	}
    

    and this too:

    
    add_filter( 'the_content', 'generate_content_filter_completed' );
    function generate_content_filter_completed( $content )
    {
    	global $generate_content_filter_completed;
    	$generate_content_filter_completed = true;
    	return $content;
    }
    

    Is that right?

    #135462
    Tom
    Lead Developer
    Lead Developer

    Well, the_title filter is used in widget titles and in other areas.

    The above code makes it only run on the page/post titles, but not in other areas (widgets, menus).

    Not sure why the above isn’t working for you – I’m assuming there might be a plugin conflict going on somewhere.

Viewing 5 posts - 16 through 20 (of 20 total)
  • You must be logged in to reply to this topic.