Archived topic
Elements Header not showing on tag archive
13 replies · Started by Carlos on November 18, 2021
Hello, thanks for this amazing plugin. I'm having an issue displaying a custom elements header in the tags archive pages for the "Directories Pro" plugin https://codecanyon.net/item/directories-pro-for-wordpress/
I've tried displaying the header in the regular wordpress tags archives and it works. Can you help me figure out what the issue is?
Thanks in advance!
Hi there,
When i inspect the page i am not seeing a specific archive template being displayed in the body classes:
https://www.screencast.com/t/Sz9kGIr67kl
it just says -template-default - which makes me think that there isn't a specific template being used for the GP Elements display rules to match to.
How is that archive page created ?
Hi David, is automatically created by the Directories pro plugin, I don't know more details about it, should I ask for some specifics about it to the developer?
Alternatively is there a way around to add a function so I can show the header using the id of the categories? as you can see in the body classes I get different id pages depending on the category that is being displayed:
%2016.47.22.png)
%2016.54.14.png)
Thanks!
You could leave the Element display rules empty and then use the generate_element_display filter:
https://docs.generatepress.com/article/generate_element_display/
For example:
add_filter( 'generate_element_display', function( $display, $element_id ) {
if ( 12345 === $element_id && is_page( 296 ) ) {
$display = true;
}
return $display;
}, 10, 2 );
Where 12345 if the is the ID of the Block Element and 296 us the ID of the page.
Hi David, I added the function as instructed but still no header is showing up
add_filter( 'generate_element_display', function( $display, $element_id ) {
if ( 8551 === $element_id && is_page( '296' ) ) {
$display = true;
}
return $display;
}, 10, 2 );
To test - if you create a simple block element - just some text, and set it the after_header hook. And set the Display Rules to All Pages - does it display on those 'archives'?
Hi David, yes it is showing up on all the website including the those archives
%2018.16.15.png)
I tweaked my snippet here:
https://generatepress.com/forums/topic/elements-header-not-showing-on-tag-archive/#post-2011283
the change being i removed the '' commas from the ID in this is_page()
I changed it but still not showing up
add_filter( 'generate_element_display', function( $display, $element_id ) {
if ( 8551 === $element_id && is_page(296) ) {
$display = true;
}
return $display;
}, 10, 2 );
Odd - can't see why it wouldn't work unless the ID is incorrect - is there anyway to check the Page ID its generating ?
Yes it's odd,
So here it's the category:
%2013.18.34.png)
This is the body class generated when accessing that category:
%2013.19.45.png)
And this is the element ID:
%2013.22.17.png)
This may be a plugin conflict w/ GP and GPP.
To test, can you check if the header will display if you remove some filters?
Example filter/s:
add_filter('drts_wordpress_archive_force_singular', '__return_true');
add_filter('drts_wordpress_archive_force_is_page', '__return_true');
add_filter('drts_wordpress_archive_force_is_not_archive', '__return_true');
Hi Elvin, I removed the filters and it's still not showing up.
Could you ask the plugin developer what Template Tags we can use to identify their archive/pages ?