Conditional Elements lets you create content with the WordPress block editor, add it to WordPress hooks, and control when it is displayed.
Create Gutenberg content, choose where it should appear, and configure conditions to control its visibility. You can include or exclude content based on configured conditions, control visibility by user role or device, and use custom WordPress action hooks when you need more flexibility.
Key Features
Placement
Conditional Elements provides theme-aware placement options based on the active theme.
For supported classic themes, additional theme-specific placement options may be available.
For other classic themes, common WordPress hook locations are available, including:
For WordPress block themes, supported placement locations include:
Available placement options depend on the active theme and its supported hooks.
You can also use Custom Hook to add content to any WordPress action hook.
Conditions
Conditional Elements provides several ways to control when content is displayed.
Include
Display content when the configured conditions match.
Exclude
Prevent content from being displayed when the configured conditions match.
User Role
Control content visibility based on the current user’s WordPress role.
Device Visibility
Control visibility based on the visitor’s device:
Shortcode
Each Conditional Element has a shortcode that can be copied directly from the Shortcode column in the Conditional Elements list table.
Example:
[hrtcel_element id=32]
Use the shortcode anywhere WordPress supports shortcodes.
The shortcode respects the Conditional Element’s configured conditions by default.
Bypass Conditions
You can optionally bypass the configured conditions by passing bypass_conditions=”true”.
Example:
[hrtcel_element id=32 bypass_conditions=”true”]
This renders the element’s content without applying its configured conditional rules.
The JavaScript and CSS files in the build/ directory are compiled from human-readable source code. The full, uncompiled source is included in this plugin in the src/ directory.
Compiled files and their sources:
build/hrtcel-admin-list.js and build/hrtcel-admin-list.css are built from src/admin-list/build/hrtcel-sidebar.js and build/hrtcel-sidebar.css are built from src/sidebar/The source is written in TypeScript/React and SCSS. The build is configured in package.json, tsconfig.json and webpack.config.js, and uses the @wordpress/scripts toolchain (webpack). Dependency versions are locked in package-lock.json.
Requirements: Node.js 20.17 or later and npm.
npm install to install the build tools.npm run build to regenerate the files in build/.npm run dev during development to rebuild automatically when files change.The following libraries are bundled into the compiled JavaScript:
All other @wordpress/* packages are loaded from WordPress core as script dependencies and are not bundled.