Site logo

Archived topic

Hero element display rule

3 replies · Started by Colas on December 1, 2020

Viewing posts 1–4 of 4

Hi,

I'm trying to disable the "global hero page header" in order to create a custom one on a custom template page.
I tried to do that by adding a filter inside functions.php like that :

add_filter( 'generate_hook_element_display', function( $display, $element_id ) {
	if ( 68 === $element_id && is_page_template('template_top_img.php')) {
		$display = false;
	}
	return $display;
}, 10, 2 );

where 68 is the ID of the "global hero page header" element, and template_top_img my custom template page. But it changes nothing.

What's wrong?
THanks for your support

Hi there,

Can you first confirm that the Exclusion under Display Rules doesn't work for you?

As for the filter, if you are referring to a header element, then try replcing generate_hook_element_display with generate_header_element_display.

HI,
Thanks! It worked, I'm now able to setup a different hero automatically on my custom template.

And yes, the Exclusion rule doesn't allow to exclude per page template (and neither the location rules). It would make sense to add such a rule.

Glad to hear :)

This archived topic is closed to new replies.