-
Hi,
I’m using GenerateBlocks Pro 2.5.0 and trying to conditionally show a GB Text block based on a custom taxonomy term assigned to a post.
I’m building a content template for a contributor section of a publication. Some articles are sponsored or guest contributions and need a visible disclosure label in the article header — similar to a format badge — that only appears when that content type is assigned to the post.
Specifically: I have a custom taxonomy called
disclosure(registered via CPT UI, show_in_rest: true, attached to post type) with two terms:sponsoredandguest-contribution. I want a Text block to render only when a specific term is assigned to the current post. Each label will have its own CSS class.I’ve looked at the Block Conditions builder and the available condition types are: Author, Cookie, Date & Time, Device, Language, Location, Post Meta, Query Parameter, Referrer, Site Options, User Meta, User Role.
There is no Taxonomy option in the list.
Is there a way to conditionally display a block based on a custom taxonomy term assignment in GB Pro 2.5.0? Or is this something that needs to be handled via Post Meta / ACF instead?
Thank you.
-
Hi there,
Condition does not support taxonomy currently.
In this case, using Post meta would be an easier option with the condition.
-
Can a GP Element display condition be used to show/hide a block based on a custom taxonomy term assigned to the current post? The reason is I have already a taxonomy set and migrating all labels to custom fields is going to be a pain. There are 300 posts.
-
Can a GP Element display condition be used to show/hide a block based on a custom taxonomy term assigned to the current post?
No, it can not; it’s for where to display the element.
If you want to use the location, a workaround would be:
1. Creating a new identical element with the text you want to display, then assigning the element to posts disclosure > the term that you want the text to display on.
2. Remove the text from the original element, and set the location to posts disclosure > the term that you do not want the text to display on.
- You must be logged in to reply to this topic.