Archived topic
Element showing up on different pages
9 replies · Started by Michael on December 4, 2020
Hi,
I have this Blog Page Header Element created from the demo content of Dev from the Site Library. It works fine and the header shows up on the blog page.
My problem is that the header also shows up on some pages created by other plugins. for example it shows up on a login page and shows up as the header of profile pages created by an LMS plugin. Since these are not actual pages, I'm not sure how to exclude them.
This element's display rules is currently set to
Location: Blog
Thanks,
Mike
Hi there,
could you share a link to an LMS page that is displaying the header element so i can see what its doing ?
Here you go:
https://libryapp.com/profile/buging/
Well thats odd, that page is listed as using the Blog template tag... what LMS are you using ?
Tutor LMS by Themeum. I also saw this strange behavior when I tested a login/registration plugin (can't recall which one). The login page generated by the plugin also used the blog header.
I am surprised that it using the Blog template tag, we would need to know what other template tags Tutor LMS uses so we can 'exclude' that using a PHP snippet. Could you ask their support if there are any template tags we can use ?
Hi David,
They are using header() tag for those pages.
Well thats not very helpful lol :)
Any chance you could ask them why those templates are not being identified correctly. They can see the page source to see that the body tag is for the Blog - which should only happen when your on the page that is set to display your latest posts....
Hi David,
I'll reach out to them. In the meantime, is there any workaround you can suggest?
Thanks,
Mike
We have this filter that would allow a Header Element to be excluded on specific display conditions:
https://docs.generatepress.com/article/generate_header_element_display/
But it does require being able to determine what conditions to check, and Tutor LMS ( looking at there documentation ) seems to lack any Template Tags that could be used to identify what template is being used....
.
Heres a possible option for that filter:
add_filter( 'generate_header_element_display', function( $display, $element_id ) {
if ( 10 === $element_id && is_page_template( ‘archive-course.php’ ) ) {
$display = false;
}
return $display;
}, 10, 2 );
the 10 needs to be changed to the ID of the Header Element, which can be found in the URL when editing the header element.
The archive-course.php would need top be changed to the template that page is using. I found a list of the templates here:
https://docs.themeum.com/tutor-lms/developers/hooks/templates/
But cannot see one for user profiles.... so i am completely at a loss to what can be done in that instance.