[Resolved] Elements On Various Pages/Posts

Home Forums Support [Resolved] Elements On Various Pages/Posts

Home Forums Support Elements On Various Pages/Posts

Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • #2150375
    Brent Wilson

    Is there a way to set one element to display on the entire site, but then have other elements that are meant to take the place of that entire site element on certain pages or posts?

    So:

    Element A – display rule: entire site

    Element B – display rule: specific page

    For Element B to replace Element A on a specific page, do I need to both include that specific page in the display rules for Element B, AND ALSO exclude that specific page in the display rules for Element A?

    Or is there a way (maybe through priority or something?) to just have Element B automatically replace Element A on that specific page just by setting the display rule for Element B to that page?

    #2150421
    Fernando
    Customer Support

    Hi Brent,

    For this, the safest route would be to set Exclude rules in the Display Rules settings.

    See: https://share.getcloudapp.com/JruONn66

    However, if you’re referring to the style we were adding through a Hook Element in the previous conversation, adding a higher priority would overwrite the lower priority in terms of CSS.

    See: https://share.getcloudapp.com/12ug6PNZ

    In other cases though, as mentioned, setting Exclude rules would be most ideal to make an Element not appear in certain pages.

    Hope this clarifies. 🙂

    #2151167
    Brent Wilson

    So basically, if I have two competing elements, I need to add it to a page/post in one element and exclude it from that page/post in the other element? So basically each time I add an additional page, I would need to go into both elements and add the page in one and exclude the page in the other?

    What I would like would be to just set one element to the entire site, and then only have to add pages/posts to the other element and have it override the site-wide element on those specific pages/posts. Is this not how elements work?

    #2151187
    Leo
    Staff
    Customer Support

    What would the content of Element B be?

    Could you just add the content of that element directly into the page if it’s only used for that page?

    #2151190
    Brent Wilson

    It could be a decorative sidebar in a different color that I want to apply to multiple pages and certain post taxonomy terms. Or a different footer that I want to apply to certain post taxonomy terms and various individual pages. Etc.

    So say I want the site-wide default footer to be built with a block element with a red background. But then I want a block element footer with a blue background applied to certain pages and post taxonomy terms. So do I need to edit both the red footer (exclude a list of pages and terms) and the blue footer (apply to the list of pages and terms)? Or is there a way to only have to edit one of the elements instead of both when I want to apply the blue footer to additional pages and terms?

    #2151191
    Leo
    Staff
    Customer Support

    Sounds like the display rule is the best solution here.

    Or you can consider using this filter for more complicated display rules:
    https://docs.generatepress.com/article/generate_element_display/

    Examples here: https://generatepress.com/forums/search/generate_element_display/

    #2151195
    Brent Wilson

    But am I understanding the display rules correctly in that one element needs to have exclusions added, while the other element needs to have display locations added? So with display rules, I am going to need to edit two different elements and the display rules on one element can’t simply override the site-wide element?

    #2151221
    Leo
    Staff
    Customer Support

    That’s basically correct.

    The elements themselves don’t have priority there is really no “overwriting” in them.

    #2151229
    Brent Wilson

    Okay. Thanks!

    #2151255
    Leo
    Staff
    Customer Support
Viewing 10 posts - 1 through 10 (of 10 total)
  • You must be logged in to reply to this topic.