Site logo

Archived topic

Issue with with Element Display Rules

28 replies · Started by Fabien on May 16, 2022

Viewing posts 1–15 of 29

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

Hi there,

so are you trying to target a Custom Taxonomy Template ?

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.

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 ?

A block element

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.

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

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.

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 :)

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

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!

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.

Is the custom taxonomy set to public: true?

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.

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 :)

This archived topic is closed to new replies.