Quick Tip GeneratePress

Make GeneratePress Default To Full-Width, No-Title On All Elementor Pages

The title says it all, but it's a mouthful, isn't it? Tom Usborne created a function for GeneratePress theme users to allow us to automatically make all Elementor pages full width, with no title.

Of course, we can already do that manually, on a page-by-page basis, but some users would prefer to have the theme default to full width, no title, and change it as needed for individual pages, rather than the other way around.

It's a simple process to get working.

Simply paste the following function code into your theme's functions.php file, or better yet, use the excellent free Code Snippets plugin to manage all your custom functions.

If you are unsure how to add the function, GeneratePress has a helpful how-to page for that.

The Function Code

You can grab the function code from here, and I'd recommend you do that, in case it ever changes in the future. But just in case, it ever disappears from there, it's documented below as well.

add_action( 'template_redirect','tu_add_elementor_filter', 999 );
function tu_add_elementor_filter() {
	if ( in_array( 'elementor-page elementor-page-' . get_the_ID(), get_body_class() ) ) {
		add_filter( 'body_class', 'tu_add_elementor_classes' );
		add_filter( 'generate_show_title','__return_false' );
	}
}

function tu_add_elementor_classes( $classes ) {
	$classes[] = 'full-width-content';
	return $classes;
}

Share With Friends

Leave a Comment