[Support request] Issue with with Element Display Rules

Home Forums Support [Support request] Issue with with Element Display Rules

Home Forums Support Issue with with Element Display Rules

Viewing 15 posts - 1 through 15 (of 17 total)
  • Author
    Posts
  • #2220806
    Fabien

    Hi,

    I’ve noticed an issue with Element Display Rules.

    Let’s say you have a CPT “Cars” and a custom taxonomy “Brand”.

    When the CPT has_archive –> False, you cannot select the Taxonomy Archive (while it stills exists) in the display rules.

    Fabien

    #2220984
    David
    Staff
    Customer Support

    Hi there,

    so are you trying to target a Custom Taxonomy Template ?

    #2221040
    Fabien

    Hi David,

    Yes I am trying to target a custom taxonomy template. I have the ability to do so when CPT has_archive –> True but not when it’s false.

    Please see screenshot in Private Information.

    #2221097
    David
    Staff
    Customer Support

    Yeah the display rules are connected to a specific post type, as Hooks are part of the Post Template which is what Elements rely on – i haven’t seen this requirement before where there isn’t a relationship between post type and archive.

    What element are you trying to use ?

    #2221327
    Fabien

    A block element

    #2221331
    Fabien

    You forget something in your reasoning : it isn’t because a CPT doesn’t have an archive (has_archive –> false) that the attached taxonomy doesn’t have an archive either.

    #2221339
    David
    Staff
    Customer Support

    What type of block element ? And what gets displayed on the taxonomy archive ? Can i see it ?

    #2221343
    Fabien

    A hook block element.

    The taxonomy archive doesn’t show up if the CPT has_archive is false (in the display rules). I believe that’s where the issue is.

    #2221403
    David
    Staff
    Customer Support

    OK so today you will need to create the block element, set the hook and NOT set the Display Rule location – ie. leave it blank.

    Then use a PHP Snippet to enable it:

    add_filter( 'generate_element_display', function( $display, $element_id ) {
        if ( 100 === $element_id && is_tax( 'your_tax_slug' ) ) {
            $display = true;
        }
    
        return $display;
    }, 10, 2 );

    update the 100 to the ID of your Element, and your_tax_slug to match your tax archive.

    Ill have a chat with Tom if its possible to display unattached taxonomy archives to the lists. But its the first time this has come up πŸ™‚

    #2221580
    Fabien

    Thanks David !

    Please note that the taxonomy is attached to the CPT πŸ˜‰

    Let me know if you need more info, happy to jump on a Zoom

    #2221609
    Ying
    Staff
    Customer Support

    Hi Fabien,

    The code David provided is assuming it’s a custom taxonomy attached to your CPT.

    Have you tried his method? Doesn’t it work?

    Let us know!

    #2221623
    Fabien

    Didn’t try yet, but I am sure it will work.

    I was just making reference to what David was saying “Ill have a chat with Tom if its possible to display unattached taxonomy archives to the lists. But its the first time this has come up πŸ™‚”

    As I mentionned, the taxonomy is attached to the CPT.

    #2221633
    Ying
    Staff
    Customer Support

    Is the custom taxonomy set to public: true?

    #2221638
    Fabien

    Yes it is πŸ˜‰ When my CPT has_archive –> True, I can target this Custom Taxonomy Archive.

    Again I think it’s a “bug” with GP Display Rules.

    #2221650
    Ying
    Staff
    Customer Support

    I see, as display rules are categorized by post types.

    When the post type doesn’t have archives, the taxonomy doesn’t attach to a post type’s archive templates, that’s what David meant πŸ™‚

    Let’s see what Tom thinks πŸ™‚

Viewing 15 posts - 1 through 15 (of 17 total)
  • You must be logged in to reply to this topic.