Site logo

Archived topic

h-Tags

19 replies · Started by Alexander on August 3, 2015

Viewing posts 16–20 of 20

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?

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!?

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;
}

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?

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.

This archived topic is closed to new replies.