https://www.advancedcustomfields.com/resources/true-false/
True / False 字段返回布尔值true
或false
。请注意,保存到数据库中的实际值是 1 或 0 的整数。
<?phpif( get_field('color') ) { // Do something.}
查询帖子
此示例演示如何查询具有true
字段“show_in_sidebar”值的帖子。
<?php$posts = get_posts( array( 'meta_query' => array( array( 'key' => 'show_in_sidebar', 'value' => '1', ) )) );if( $posts ) { foreach( $posts as $post ) { // Do something. }}
转载请注明:Wordpress» WordPress True / False功能参数
标签: