Meta Boxes Visibility Conditions Overview
From this tutorial, you will learn how to add Visibility Conditions to Meta Boxes with the WordPress JetEngine plugin.
Meta Box is a container for meta fields in the WordPress JetEngine plugin. It stores the meta fields you put inside and helps to organize and maintain them. You can add meta boxes to any post type, user, or taxonomy. But what if you need to show meta boxes to the administrator or hide them from the editor? Do you need to apply meta boxes to some exact posts or terms? That is doable with the Visibility Conditions feature.
Proceed to JetEngine > Meta Boxes. After the General Settings tab, you can see the Visibility Conditions. That’s how they look if you select “Post” in the Meta Box for field.
You can add any Post Types to the Enable For Post Types field for the meta box visibility condition. This field is required because it should specify where conditions will be applied. After you hit the “+ New condition” button, you will see the Add new condition field.
Such options are available in this drop-down menu:
- Include Posts. Here you can enter the names of posts that you want the meta box to be shown for;
- Exclude Posts. Here you can enter the names of posts that you want to exclude the meta box from;
- Included for User Roles. Here you can specify the user roles that such meta box will be shown for;
- Exclude for User Roles. Specify here the user roles that will be unable to see meta boxes;
- Post Has Taxonomy Terms. Choose the taxonomy name in the drop-down menu and enter the names of the terms in the nearby field.
After you set one condition, you can add another one. Feel free to add as many conditions as you need.
We have quite familiar settings for the Taxonomy meta boxes. The difference is that you should select the taxonomies for visibility conditions. And there are only two available conditions — Included for User Roles and Exclude for User Roles.
If you create a meta box for User, a new Visible at selector with two new options will appear:
- Edit User. It adds meta fields to the Edit User page. Since only administrators can edit users, such fields became visible only to people with such a role;
- Edit User & Profile. This option adds meta fields to the Edit User page and the Profile Page, which users can edit.
Meta boxes for User also have the same two conditions: Included for User Roles and Exclude for User Roles.
That’s all. Add as many conditions as you need and organize the meta fields on the WordPress website faster and easier.