Elementor CPT Title Display Condition
A lightweight WordPress plugin that extends Elementor Pro's **Display Conditions** feature to cover custom post types.
by Luke Lanza · github.com/aznalfl/elementor-cpt-title-display-condition
Install
No release zip yet. The repository archive installs, but the folder name will carry the branch suffix and updates will not flow:
wp plugin install https://github.com/aznalfl/elementor-cpt-title-display-condition/archive/refs/heads/main.zipA lightweight WordPress plugin that extends Elementor Pro's Display Conditions feature to cover custom post types.
Out of the box, Elementor Pro's Post Title condition only lets you pick from entries of the built-in post post type. This plugin adds an equivalent condition — "[Post Type] Title" — for every other public custom post type registered on your site (e.g. Products, Movies, Team Members), so you can show or hide any widget or container based on a specific CPT entry.
Requirements
- WordPress 6.0+
- PHP 8.0+
- Elementor (free)
- Elementor Pro (Display Conditions feature must be available on your license)
Installation
- Copy the
elementor-cpt-title-display-conditionfolder intowp-content/plugins/ - Activate Elementor CPT Title Display Condition via Plugins → Installed Plugins
- No configuration is required — the plugin reads your registered public custom post types automatically
Usage
- Open any page, template, or archive in the Elementor editor
- Select a widget, container, or section and open its Advanced tab
- Click Display Conditions → + Add Condition
- Under the Post group, choose "[Your CPT] Title" (e.g. Product Title, Movie Title)
- Set the comparator to Is or Is Not
- Type to search for and select one or more published entries of that custom post type
- Save — the element will only render when the current page's title matches (or doesn't match) your selection
How It Works
The plugin hooks init at priority 999 (after custom post types, which register at the default priority 10, and after Elementor Pro builds its Conditions_Manager on init priority 0). At that point it:
- Confirms Elementor Pro's Display Conditions classes and the conditions manager component exist (no-ops safely if not — see Limitations below)
- Calls
get_post_types( [ 'public' => true, '_builtin' => false ] )to collect every public custom post type, automatically excludingpost,page, andattachment(built-ins, already covered by Elementor Pro's own conditions) - Registers one
Cpt_Title_Conditioninstance per custom post type via Elementor Pro's officialregister_condition_instance()API
Each Cpt_Title_Condition extends Elementor Pro's own Title_Condition_Base — the same abstract class its built-in Post Title and Page Title conditions use — and only overrides get_query() to scope the underlying post lookup (and the searchable title picker) to that post type. This means the comparator logic, the Query Control search UI, and the title-matching check() logic are all inherited directly from Elementor Pro, rather than reimplemented.
Files
elementor-cpt-title-display-condition.php— plugin bootstrap: requirement guards, admin notice, and per-post-type condition registrationconditions/class-cpt-title-condition.php— theCpt_Title_Conditionclass (loaded lazily, only after Elementor Pro's base class is confirmed to exist)
Assumptions & Limitations
- One condition per post type, not a single combined picker. The plugin registers a separate condition ("Product Title", "Movie Title", …) for each custom post type, matching the pattern of the existing
elementor-custom-taxonomy-display-conditionsplugin in this workspace, rather than one condition with a post-type dropdown plus a dependent item picker. This keeps each condition's search results scoped and unambiguous, and requires no custom JS/UI — but it means the condition list grows by one entry per public CPT. - Public post types only, per the requirement. Private, internal, or non-publicly-queryable post types (e.g.
public => false) are intentionally skipped, matching how Elementor Pro itself scopes similar features. - Published entries only. Like Elementor Pro's own Post Title condition, the search picker only surfaces posts with
post_status => publish. post,page, andattachmentare excluded since Elementor Pro already ships dedicated conditions for the first two, andattachmentis not a meaningful "title" target for this use case.- If Elementor Pro (or its Display Conditions license feature) is unavailable, registration silently no-ops — no fatal errors, just no extra conditions in the list. An admin notice is shown if Elementor Pro itself isn't active.
- The
Requires Pluginsheader only declareselementor, notelementor-pro. Elementor Pro is a premium plugin distributed outside WordPress.org, so it can't be reliably resolved through the native plugin-dependency mechanism in every environment. Elementor Pro's presence is instead verified at runtime viaclass_exists()guards, which is safer and is what actually prevents fatal errors if it's inactive. - If a CPT is later removed or this plugin is deactivated, any saved condition referencing it is treated by Elementor Pro's own
And_Conditionevaluator as passing (non-restrictive) rather than fataling, since it can no longer resolve a condition instance for that name. This is the same behavior the existing taxonomy-conditions plugin relies on. - This matches by title, not by post ID. The condition inherits its matching logic directly from Elementor Pro's
Title_Condition_Base::check(), which compares the current post's title against the titles of the selected entries — it is not a strict "current post ID equals selected CPT item" check. If two different items (in the same or even a different post type) happen to share the exact same title, the condition may match on title text alone rather than uniquely identifying the item you picked. This mirrors the same behavior as Elementor Pro's own built-in Post Title and Page Title conditions.
Manual Testing Checklist
This was built and reviewed against Elementor Pro's own source (Title_Condition_Base, Post_Title_Condition, Page_Title_Condition, Conditions_Manager) but has not been executed against a live WordPress install. Before relying on it, verify:
- Register or use an existing public custom post type (e.g. WooCommerce Products, or a quick test CPT with
public => true) with a few published entries - Activate this plugin alongside Elementor and Elementor Pro
- In the Elementor editor, open Display Conditions → + Add Condition and confirm a "[Your CPT] Title" entry appears under the Post group
- Add the condition, select one or more entries, save
- View a matching CPT entry's page and confirm the element shows (for Is) or hides (for Is Not)
- View a non-matching page (a different CPT entry, or an unrelated post/page) and confirm the opposite behavior
- Deactivate Elementor Pro and confirm no fatal errors occur, and the admin notice appears
- If applicable, test with more than one custom post type active to confirm each gets its own correctly-labeled, correctly-scoped condition
Author
Luke Lanza