Site logo

Archived topic

Elements Header not showing on tag archive

13 replies · Started by Carlos on November 18, 2021

Viewing posts 1–14 of 14

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:

screenshot
screenshot

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

ss

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:

This is the body class generated when accessing that category:

And this is the element ID:

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 ?

This archived topic is closed to new replies.