Tag config options
Tag config options provide a versatile way to customize tag-related content on your website. You can access these options in the right-sidebar of the Edit Tag screen under the Other Options section.
It is important to note that these options also appear in the Theme Settings screen under the Tag Options section. The settings configured here serve as default values for all tags, which can be individually adjusted for each tag in the Other Options section mentioned above.
Similar to post config options, tag config options can be included or excluded in the tagConfig section of the config.json file.
How to add a custom tag option?
There are several tag config options available. Let's see an example of how to add a select element to enable/disable the display of the post counter on the tag page:
"tagConfig": [
{
"name": "displayPostCounter",
"label": "Display post counter",
"value": 1,
"type": "select",
"options": [
{
"label": "Enabled",
"value": 1
},
{
"label": "Disabled",
"value": 0
}
]
}
]
In the code above, we:
- Specified the Name of the variable using the name attribute.
- Used the Label attribute to provide the option's name as it will appear in the sidebar.
- Set the default behavior with the Value attribute; using 1 means that the option will be enabled by default.
- Defined the Type attribute as select to create a select element with a drop-down list.
- In the Options section, defined each option available in the drop-down list and what variables it will change.
How to use tag config options?
To use tag config options in the tag.hbs file, you can use the following markup:
{{#if tagViewConfig.displayPostCounter}}
<sup>({{postsNumber}})</sup>
{{/if}}
When you change the option to "Disabled", the post counter will not be displayed.
Note: all options can be used within conditions (i.e. if statements)
Available tag config option types
The example above uses only one option type, but you can utilize various elements to expand the tag content.
The available option types are:
These option types can be used similarly to the post config options, allowing you to create a customizable experience for your tag-based content. For a detailed description of each option type, please refer to the post config options article.