- This topic has 7 replies, 2 voices, and was last updated 2 years, 3 months ago by David.
-
AuthorPosts
-
April 22, 2020 at 5:17 pm #1250131Steven
Is there a way to have an element either apply to or be excluded from a particular URL path. We’re trying to integrate BetterDocs for our internal help system in WordPress for our content editors. When we try to exclude the site header and footer from the Docs post type, it works for that particular custom post. However, it has some category and keyword custom post types as well. While we could add every category and keyword to exclude the header/footer elements, we’d have to touch this element every time we added a new category or element. It would be nice to have the display rule option of “exclude everything under /docs* on the site” or something like that. There are actually several elements we inject for our header and footer, so manually updating all of these with the category and tag display rules would be cumbersome. Happy to look at alternatives as well if there’s a better strategy.
We haven’t made the docs private yet, so you can reproduce what we’re experiencing by going to the URL in this ticket and then selecting the “News” category. That will take you to a category page where parts of the header and footer aren’t suppressed.
April 23, 2020 at 4:47 am #1250999DavidStaffCustomer SupportHi there,
with the Display rules i would expect to see something like
docs
for the singles anddocs archive
– surely you could just exclude those two locations?Let me know.
April 23, 2020 at 3:26 pm #1252229StevenI recall seeing doc archives in the settings at one time and then couldn’t find it later. I discovered there’s a setting in BetterDocs (Enable Built-in Documentation Page). If you deselect this option choose your own custom starting page for documentation (i.e. a regular WordPress page that you add shortcodes to), then the Docs Archive option disappears in the GP Elements display rules screen. Reselecting this option made the archives option available and we’re able to suppress what we need to.
Thanks for the tip David!
April 24, 2020 at 1:20 am #1252769DavidStaffCustomer SupportGlad to be of help 🙂
December 30, 2021 at 10:34 pm #2064517ChadHi,
I had this same question.
In the exclude options, you can only select individual pages.
Is there a way to exclude the Element from all pages in a path?
ex. website.com/services; website.com/services/service-one; website.com/services/service-two; etc.
Thanks!
December 31, 2021 at 6:42 am #2064760DavidStaffCustomer SupportHi there,
If that is for Page Parents and Children, then not from within the Display Rules.
But you can use thegenerate_element_display
filter:https://docs.generatepress.com/article/generate_element_display/
For example this PHP Snippet:
add_filter( 'generate_element_display', function( $display, $element_id ) { global $post; if ( 100 === $element_id && 123 == $post->post_parent ) { $display = false; } return $display; }, 10, 2 );
Will remove the element from a child of a parent post.
The100
needs to be changed to the ID of the Element. And the123
the ID of the Parent post.December 31, 2021 at 9:58 am #2065055ChadThanks! That seemed to work!
You can use the Display rules as well as that snippet to exclude other pages/sections.
Thanks again!
December 31, 2021 at 10:00 am #2065060DavidStaffCustomer SupportGlad to hear that!
-
AuthorPosts
- You must be logged in to reply to this topic.