Advanced Title and Content fields
Displaying custom fields, taxonomy terms and user meta fields within the live result titles or contents
Last updated
Displaying custom fields, taxonomy terms and user meta fields within the live result titles or contents
Last updated
With these options you can combine or replace more fields to the title and description field. There are two default variables:
{titlefield}
- this is the default title value as set on the title field
{descriptionfield}
- the default description value as set on the description field
..as well as a number of special variables:
Anything besides these inside "{}" crates is treated as a custom field name or taxonomy name if prefixed with '_taxonomy_' or '__tax_' words. These fields support HTML tags as well.
{custom_field}
This will print the content of the custom field (post meta) named 'custom_field'.
{__um_custom_field}
{_taxonomy_category}
or{__tax_category}
This will print 5 items from the category taxonomy, separated by comma. These values are changeable via arguments, as well as other things:
{__tax_category count=5 separator=', ' orderby='name' order='ASC' exclude='1'}
Accepted arguments:
count - (int) number of terms to print, default: 5
separator - (string) separator between the items, default: ', '
orderby - (string) the ordering criteria ( 'name', 'slug', 'term_group', 'term_id', 'id', 'description', 'parent'), default: 'name'
order - (string) the ordering direction ('ASC', 'DESC'), default 'ASC'
exclude - (string) comma separated list of excluded terms from the list, default: '1' (aka. the Uncategorized category)
For date fields such as Events calendar or other plugin date fields, the date_format argument can be used to pass the date format. The list of accepted PHP date format parameters can be found here.
Example
..will output:
Example 1: You have a custom field called 'location', which holds the location name for each post, and you want to display it before the description, separated by comma.
The simplest solution would be:
You can use HTML tags in this field as well, so let's display the location in bold letters:
Example 2: You have WooCommerce installed and you want to output the title in the following format: "Product name - 10$"
In this case the _price custom field holds the price of a product. Then simply try the following input in the Advanced title field:
Note, that you don't need the currency symbol, the plugin will automatically detect and display it along with the formatted price! (only works with WooCommerce)
Equivalently, as in the previous example, displaying the price in strong letters:
Other notable WooCommerce fields:
_price_html
- will display the original output of the price field, requested from WooCommerce, this includes the regular and sale price when available, like: 25.00$ 22.00$
_regular_price
- the regular price
_sale_price
- the sale price
_sku
- The product SKU field
_stock
- Product stock count
_stock_status
- Either "instock" or "outofstock"
Example 3: You want to display 2 post categories before the post content, separated by space.
The category taxonomy contains the post categories, so the syntax is:
Resulting in:
Notice, that the taxonomy field is placed into a paragraph, so it shows up in a new line.
Conditional brackets are used to display custom fields, only if they have values, simple as that. If the fields in the conditional brackets does not have value or does not exist, then everything in the bracket is ignored.
..where {field1} to {fieldN} is replaced with their values, and the text between the fields is displayed as it is. HTML is supported. If any of the fields is empty or does not exist, then nothing from the brackets is displayed. This becomes especially handy, if the custom fields are only set on some of the post type objects.
You have WooCommerce and want to display some text and the price in the title, but some items does not have prices. Like so: Item title - Price: 10.0$
You need to use conditional brackets, as you don't want to display the '- Price' text if there is no price set:
This will result in:
You have WooCommerce and want to display some text and the sale price, if not on sale, then the regular price in the title - but some items does not have prices. Like so: Item title - Now only: 9$ instead of - 10.0$
You need to use conditional brackets, as you don't want to display the '- Price' text if there is no price set:
This will result in: