麦客网络帮助中心

登陆后台
产品管理
独立站装修
内容管理
SEO设置
子账号开设
高级设置

自定义字段

Custom Fields Usage

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 #

  1. Go to Impreza > Addons admin page and install the “Advanced Custom Fields” via a single click
  2. Go to Custom Fields > Add New to create a Field Group
  3. Enter any title (e.g. “Posts”), click the “+ Add Field” button, and enter “Subtitle” into Field Label
    2369.png
    2370.png
  4. Scroll down to the “Settings” area, set Style as “Seamless (no metabox)” and Position as “High (after title)
    2371.png
  5. Scroll up and click the “Publish” button at the top-right part of the screen.
  6. Go to Impreza > Content Templates and create a Content Template or use an existing one.
  7. Add “Post Custom Field” element and select showing “Posts: Subtitle” in its settings
    2627.png
  8. Go to Impreza > Themes Options > Pages Layout and set that Content Template as the content of posts
    2610.png
  9. 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
    2376.png

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:

2589.png

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:

2590.png

After that every house page will display values from its custom fields, like:

2591.png

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
上一篇
备份专题
菜单