- This topic has 28 replies, 4 voices, and was last updated 1 year, 1 month ago by Fabien.
-
AuthorPosts
-
May 16, 2022 at 1:00 am #2220806Fabien
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
May 16, 2022 at 4:44 am #2220984DavidStaffCustomer SupportHi there,
so are you trying to target a Custom Taxonomy Template ?
May 16, 2022 at 6:13 am #2221040FabienHi 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.
May 16, 2022 at 7:30 am #2221097DavidStaffCustomer SupportYeah 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 ?
May 16, 2022 at 7:55 am #2221327FabienA block element
May 16, 2022 at 7:57 am #2221331FabienYou 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.
May 16, 2022 at 8:09 am #2221339DavidStaffCustomer SupportWhat type of block element ? And what gets displayed on the taxonomy archive ? Can i see it ?
May 16, 2022 at 8:11 am #2221343FabienA 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.
May 16, 2022 at 9:23 am #2221403DavidStaffCustomer SupportOK 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, andyour_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 π
May 16, 2022 at 12:05 pm #2221580FabienThanks 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
May 16, 2022 at 12:30 pm #2221609YingStaffCustomer SupportHi 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!
May 16, 2022 at 12:31 pm #2221623FabienDidn’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.
May 16, 2022 at 12:44 pm #2221633YingStaffCustomer SupportIs the custom taxonomy set to
public: true
?May 16, 2022 at 12:47 pm #2221638FabienYes 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.
May 16, 2022 at 1:02 pm #2221650YingStaffCustomer SupportI 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 π
-
AuthorPosts
- You must be logged in to reply to this topic.