post_meta 条件
名字 |
描述 |
'post_format' |
根据post格式进行检查。使用空白字符串作为值来测试post是否未分配格式。 |
'post_id' |
根据post ID 进行检查。 |
'post_level' |
根据层次结构中的职位级别进行检查。级别从 1 开始。 |
'post_parent_id' |
检查post的父 ID。 |
'post_ancestor_id' |
检查post的祖先。 |
'post_template' |
检查post的模板文件名。作为要针对默认页面模板测试的值传递。
default |
'post_term' |
根据post的条款进行检查。预期值必须是term描述符(见下文)。 可调用的传递post的ID。
CUSTOM |
'post_type' |
根据post的类型进行检查。 |
// Display container on Books CPT
Container::make( 'post_meta', __( 'Book Data' ) )
->where( 'post_type', '=', 'crb_book' )
->add_fields( array( .. ) );
// Display container on page that uses the template `templates/homepage.php`
Container::make( 'post_meta', __( 'Homepage Settings' ) )
->where( 'post_type', '=', 'page' )
->where( 'post_template', '=', 'templates/homepage.php' )
->add_fields( array( .. ) );
term_meta条件
名字 |
描述 |
'term' |
根据提供的term描述符对照term进行检查。 可调用传递term的 ID。CUSTOM |
'term_level' |
在层次结构中检查term的级别。 |
'term_parent' |
对照term的父级进行检查。 |
'term_ancestor' |
检查该term的祖先。 |
'term_taxonomy' |
根据term的分类进行检查。 |
// Display container on Book Category taxonomy
Container::make( 'term_meta', __( 'Book Category Data' ) )
->where( 'term_taxonomy', '=', 'crb_book_category' )
->add_fields( array( .. ) );
user_meta条件
名字 |
描述 |
'user_capability' |
根据用户的功能进行检查。 可调用传递用户的 ID。CUSTOM |
'user_id' |
检查用户的 ID。 |
'user_role' |
根据用户的角色进行检查。 可调用的传递是用户角色的数组。CUSTOM |
// Display container on for Administrators only
Container::make( 'user_meta', __( 'Administrator' ) )
->where( 'user_role', '=', 'administrator' )
->add_fields( array( .. ) );
theme_options条件
名字 |
描述 |
'blog_id' |
检查当前博客的 ID |
一般可用条件
以下条件适用于任何容器,并取决于当前用户
名字 |
描述 |
'current_user_capability' |
根据当前用户的功能进行检查。 可调用传递当前用户的 ID。CUSTOM |
'current_user_id' |
检查当前用户的 ID。 |
'current_user_role' |
检查当前用户的角色。 可调用传递的所有当前用户角色的数组。CUSTOM |
// Display theme options page to users who have the 'manage_options' capability
Container::make( 'theme_options', __( 'Theme Options' ) )
->where( 'current_user_capability', '=', 'manage_options' )
->add_fields( array( .. ) )
Term描述符
term相关条件期望您为它们提供term描述符作为值(and 运算符的term描述符数组)。
term描述符是具有以下键的数组:INNOT IN
钥匙 |
描述 |
field |
要与之比较的term字段。 |
value |
term字段的值。 |
taxonomy |
term的分类。 |
用法示例
Container::make( 'post_meta', 'Custom Data' )
->where( 'post_term', '=', array(
'field' => 'slug',
'value' => 'featured',
'taxonomy' => 'category',
) )
有关这些值的更多信息,请参阅get_term_by()
函数在 WordPress 代码参考中(此处的三个键与此函数的前三个参数相同)。