WP Manifestindependent plugin directory
manifest / builders / elementor-cpt-title-display-condition

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

0stars
0forks

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.zip

A 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

  1. Copy the elementor-cpt-title-display-condition folder into wp-content/plugins/
  2. Activate Elementor CPT Title Display Condition via Plugins → Installed Plugins
  3. No configuration is required — the plugin reads your registered public custom post types automatically

Usage

  1. Open any page, template, or archive in the Elementor editor
  2. Select a widget, container, or section and open its Advanced tab
  3. Click Display Conditions → + Add Condition
  4. Under the Post group, choose "[Your CPT] Title" (e.g. Product Title, Movie Title)
  5. Set the comparator to Is or Is Not
  6. Type to search for and select one or more published entries of that custom post type
  7. 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:

  1. Confirms Elementor Pro's Display Conditions classes and the conditions manager component exist (no-ops safely if not — see Limitations below)
  2. Calls get_post_types( [ 'public' => true, '_builtin' => false ] ) to collect every public custom post type, automatically excluding post, page, and attachment (built-ins, already covered by Elementor Pro's own conditions)
  3. Registers one Cpt_Title_Condition instance per custom post type via Elementor Pro's official register_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 registration
  • conditions/class-cpt-title-condition.php — the Cpt_Title_Condition class (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-conditions plugin 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, and attachment are excluded since Elementor Pro already ships dedicated conditions for the first two, and attachment is 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 Plugins header only declares elementor, not elementor-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 via class_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_Condition evaluator 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:

  1. 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
  2. Activate this plugin alongside Elementor and Elementor Pro
  3. In the Elementor editor, open Display Conditions → + Add Condition and confirm a "[Your CPT] Title" entry appears under the Post group
  4. Add the condition, select one or more entries, save
  5. View a matching CPT entry's page and confirm the element shows (for Is) or hides (for Is Not)
  6. View a non-matching page (a different CPT entry, or an unrelated post/page) and confirm the opposite behavior
  7. Deactivate Elementor Pro and confirm no fatal errors occur, and the admin notice appears
  8. 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