-
Notifications
You must be signed in to change notification settings - Fork 10
Extensions Conditional Visibility
Added in 2.1.0
Controls whether a block is rendered based on per-item data when the block is inside a Dynamic Query. Rules evaluate against the queried item's post meta, taxonomy terms, loop index, or authentication state. Blocks without rules are always visible.
This is different from Responsive Visibility (
RESPONSIVE-VISIBILITY.md), which shows or hides blocks based on device screen size. Conditional Visibility acts at render time on the server and reflects the data of each loop item.
Every block receives a dsgoVisibility attribute (type object, default null). The attribute holds a { operator, rules[] } structure. On the frontend, a render_block filter compares the rules against the current item context pushed by Dynamic Query onto $GLOBALS['designsetgo_parent_stack']. Blocks that do not match are suppressed (rendered as an empty string). The editor canvas mirrors this evaluation inside query-item previews using the same rule logic compiled to JavaScript.
Blocks outside a Dynamic Query context are unaffected — visibility rules are only evaluated when the item-context stack is non-empty. This applies to every rule type, including Auth State: a logged-in/out rule on a block that is not inside a Dynamic Query will be ignored. The intent is to keep this extension focused on per-item rendering inside loops; for global "show only to logged-in users" use cases on standalone pages, use a core Block Visibility plugin or wp_get_current_user() in a custom block.
Open any block's settings, expand Advanced, then find the Visibility panel.
Click Add rule. Each rule row has a Rule Type dropdown plus type-specific fields:
-
Meta Key — the
_meta_keyto read from the current post -
Condition —
equals,does not equal,contains,is set,is not set -
Value — the comparison string (hidden for
is set/is not set)
-
Taxonomy Slug — e.g.
category,post_tag, or a custom taxonomy -
Condition —
has term/does not have term - Term Slug — the term to check membership for
-
Condition —
is,is not,less than,greater than - Index Value — numeric position
-
Visibility requires —
Logged-in userorLogged-out visitor
When two or more rules are present a Combine Rules dropdown appears:
- All rules must match (AND) — block renders only if every rule passes
- Any rule must match (OR) — block renders if at least one rule passes
Remove any rule with its Remove button. Removing the last rule resets the attribute to null (always visible).
Evaluation runs server-side inside BlockVisibility::filter_render_block(). The filter is only active while inside a designsetgo_query_render_item() call; top-level page blocks are never affected.
Add custom rule types via the designsetgo_visibility_rule filter:
add_filter(
'designsetgo_visibility_rule',
function ( $match, $rule, $context ) {
if ( $rule['type'] !== 'my-custom-type' ) {
return $match; // pass through — let other handlers run
}
return my_custom_check( $rule, $context ); // return bool
},
10,
3
);The filter receives ($match, $rule, $context) → bool|null. Return null to fall through to the default (false).
- The extension does not apply to
core/freeform,core/missing, orcore/template-part. - Rules are stored in block markup as a serialized JSON object inside the block comment delimiter.
-
hasandnot_hasoperators are specific to taxonomy rules;gtandltare specific to index rules. The full operator set is:equals,not_equals,contains,gt,lt,empty,not_empty,has,not_has.
Auto-generated from
docs/extensions/CONDITIONAL-VISIBILITY.md. To update, edit the source file and changes will sync on next push to main.
- Accordion
- Advanced Heading
- Blobs
- Breadcrumbs
- Card
- Chart
- Comparison Table
- Countdown Timer
- Counter Group
- Divider
- Dynamic Image
- Fifty Fifty
- Flip Card
- Form Builder
- Grid
- Hotspot
- Icon
- Icon Button
- Icon List
- Image Accordion
- Map
- Modal
- Modal Api Reference
- Modal Auto Triggers
- Modal Fse Compatibility
- Modal Gallery Navigation
- Modal Trigger
- Pill
- Product Categories Grid
- Product Showcase Hero
- Progress Bar
- Query
- Query Filter
- Query Group Header
- Query No Results
- Query Pagination
- Query Results
- Row
- Scroll Accordion
- Scroll Marquee
- Scroll Slides
- Section
- Section Divider
- Slider
- Star Rating
- Sticky Sections
- Table Of Contents
- Tabs
- Text Path
- Timeline
- Background Video
- Block Animations
- Clickable Group
- Conditional Visibility
- Custom Css
- Draft Mode
- Dynamic Tags
- Expanding Background
- Grid Mobile Order
- Grid Span
- Hover Effects
- Max Width
- Responsive Visibility
- Reveal Control
- Scroll Parallax
- Sticky Header
- Style Binding
- Svg Patterns
- Text Alignment Inheritance
- Text Reveal
- Abilities Api
- Abilities Api Guide
- Block Bindings
- Draft Mode Api
- Interactive Blocks
- Markdown Content Negotiation
- Rest Api Reference
- Wp Cli Reference
- Ai Assisted Development
- Best Practices Summary
- Block Controls Organization
- Block Development Best Practices Comprehensive
- Block Exclusion Guide
- Deploying To Wordpress Org
- Design System
- 2026 04 16 Blocks Editor Ux Design
- 2026 04 17 Theme 3 Inspector Ia
- 2026 04 21 Query Block Onboarding
- 2026 04 21 Query Capable Layout Blocks Design
- 2026 04 27 Block Roadmap Ideas
- 2026 07 01 Shape Divider Theme Inheritance
- 2026 07 02 Icon Block Dynamic Render Pilot
- 2026 07 06 Section Divider Block Design
- 2026 07 06 Section Style Variations Fse Design
- 2026 07 06 Section Styles Editor Preview
- 2026 07 07 Row Grid Overlay Hover Parity Design
- 2026 07 21 Conditional And Dup Label Sourcing
- 2026 07 23 Theme Block Type Animation Defaults
- 2026 08 16 Chart Block
- 2026 08 16 Greenshift Gap Roadmap
- 2026 08 17 Woocommerce Surface
- 2026 08 24 Loop Carousel
- 2026 08 24 Star Rating Block
- 2026 09 17 Abilities Drift Prevention
- 2026 09 17 Abilities Drift Prevention Implementation
- 2026 09 29 Existing User Regression Fixes
- 2026 09 29 Release Preflight Fixes
- Readme
- 2026 07 02 Block Authorability Audit
- 2026 09 29 Regression Fixes
- 2026 09 29 Release 2.9.0
- 2026 09 29 Release Fixes