Custom Fields Usage
Updated 3 weeks 3 days ago
Custom fields are used to show editable information on posts, pages, or any custom post types. Impreza has built-in custom fields, like the “Page Layout” box. To create your own additional fields we recommend using the Advanced Custom Fields plugin. Read an example of usage below.
How to add “Subtitle” to posts via Advanced Custom Fields #
- Go to Impreza > Addons admin page and install the “Advanced Custom Fields” via a single click
- Go to Custom Fields > Add New to create a Field Group
- Enter any title (e.g. “Posts”), click the “+ Add Field” button, and enter “Subtitle” into Field Label
- Scroll down to the “Settings” area, set Style as “Seamless (no metabox)” and Position as “High (after title)”
- Scroll up and click the “Publish” button at the top-right part of the screen.
- Go to Impreza > Content Templates and create a Content Template or use an existing one.
- Add “Post Custom Field” element and select showing “Posts: Subtitle” in its settings
- Go to Impreza > Themes Options > Pages Layout and set that Content Template as the content of posts
- Go to edit any existing post or create a new one, you will see a new “Subtitle” field. Enter some text and it will appear on your post
How to show Custom Field values in other elements #
Some theme elements may use dynamic values via {{custom_field_name}} shorthand. Dynamic value takes the value from a custom field of the current post (page, product, etc.). If the custom field doesn’t exist, then returns an empty string.
For example, the Real Estate demo has the following ACF fields:
If you add Text element with
{{storeys}}-storey house with living area of {{living_area}} sqm, with {{bedrooms}} bedrooms, located on a plot of {{land_area}} sqm.
text into “House Page” Content template:
After that every house page will display values from its custom fields, like:
Elements with dynamic values support #
- Accordion (Section Title field)
- ActionBox (Title, Buttons Label fields)
- Button (Button Label field)
- Contact Info (all fields)
- Counter (Final counting value, Title fields)
- Dropdown (Title field)
- FlipBox (Title, Description, Button Label fields)
- IconBox (Title field)
- Interactive Banner (Title, Description fields)
- Map (Custom address, Marker Text fields)
- Person (Name, Role fields)
- Pricing Table (all fields)
- Progress Bar (Progress Value, Final Value, Title fields)
- Separator (Title field)
- Tabs/Vertical Tabs (Section Title field)
- Text (Text field)
- Video Player (Link field)
Predefined dynamic values #
- {{comment_count}} – shows comments amount of the current post (reviews amount of a WooCommerce product)
- {{post_count}} – shows the total amount of published posts
- {{user_count}} – shows the total amount of registered users