The Entity Field block and shortcode allow you to display a single ChroniclePress field value anywhere within your content.
This is useful when you want to pull structured data from a Person, Place, or Source and display it inline within an article, page, template, or custom layout. The block is dynamically rendered, meaning updates to entity data are automatically reflected everywhere the block or shortcode is used.
There are two methods to display entity field data. If you use the native WordPress Gutenberg post editor, choose the block method. If you are using a page builder or the classic WordPress editor, use the shortcode method.
The Entity Field Block #
Adding an Entity Field Block #
1. Open the post or page where you want to add the field data.
2. Click the + button to add a new block (either in the content area or in the block inserter panel on the left). Search for Entity Field and click it.
3. The block appears in your content with a prompt asking what field you would like to display. Select the ChroniclePress field whose data you wish to show. Available fields depend on the entity type and any installed ChroniclePress Layers.
4. If you want to pull the data from the current post being edited, select This Post. If you want data from another ChroniclePress post, select A specific entity. Select the entity type and search for the post whose data you wish to display.
5. The block immediately shows the selected field value.
Labeling Data #
With the Entity Field block selected, look at the right-hand sidebar — you’ll see several options under Display Options.
If you wish to show a text-based label before the value, turn on Show field label. By default, this setting will display the field name before the value.
Example:
Birth Date: 1820
You can also override the default field label by typing your desired label in the Custom Label Text option.
Example:
Instead of:
Birth Date: 1820
Display:
Born: 1820
Fallback Text #
The Fallback Text option is useful if a returned field has no value. Continuing with our birthdate example, if you elect to show the birth date value for a person who has no birth date entered, the field will return no value, and thus nothing will display. Instead, you might want to display the text “date unknown“.
Auto-Link URL Values #
When enabled, URL fields automatically become clickable links.
The Entity Field Shortcode #
The Entity Field shortcode allows you to display a single ChroniclePress field value anywhere shortcodes are supported.
This is especially useful when working with:
- Classic Editor
- Elementor
- Beaver Builder
- Divi
- Widgets
- Theme templates
Basic Usage #
Display A Field from the Current Entity #
[cp_field field="birth_date"]
Displays the selected field from the current entity with the default label.
Display A Field from a Specific Entity #
To show a field from a specific entity, you will need the post ID of the entity’s data you wish to display. You can find the post ID in the edit URL of the entity post.
[cp_field field="birth_date" id="123"]
Displays the birth date from the entity with ID 123.
Displaying Field Labels #
Hide the Field Label #
[cp_field field="birth_date" label="none"]
Output – Birth Date: 1820
Use a Custom Label #
[cp_field field="birth_date" label="Born"]
Output – Born: 1820
Displaying Fallback Text #
[cp_field field="birth_date" fallback="Unknown"]
If the field is empty, the shortcode will output: Unknown
Automatically Link URLs #
[cp_field field="source_url" link="yes"]
All URL output will be rendered as a clickable link.
Customizing Output #
Adding a css class #
[cp_field field="birth_date" class="my-custom-class"]
Adds a custom class to the output’s <span> wrapper, allowing you to style it using your own CSS.
Prepending and appending html #
[cp_field field="birth_date" before="<div>" after="</div>"]
The shortcode parameters before and after allow you wrap the output in custom HTML or add icons or text before and after the <span></span> tag output wrapper.
Available Parameters #
Below is a list of all available parameters for the shortcode. You can mix and match all available parameters to completely customize the output to your exact need.
| Parameter | Description |
|---|
| field | Field key to display |
| id | Specific entity ID |
| label | Show field label (yes/no) |
| fallback | Text shown when field is empty |
| link | Auto-link URL values |
| class | Additional CSS class |
| before | HTML or text printed before the output. |
| after | HTML or text printed after the output. |
Example #
[cp_field field="birth_date" id="123" label="Born in" link="yes" class="my-css-class" before="*"]
