Wordpress - 在“posts_where”过滤器中获取帖子元

问题描述 投票:0回答:1

如何检查帖子元字段是否等于“posts_where”过滤器中的某些内容?我想跳过自定义字段“my_meta_box_check”设置为“关闭”的帖子。

wordpress plugins custom-fields
1个回答
2
投票

你可以这样做:

function filter_where( $where = '' ) {
   global $wpdb;  
   $where .= " AND ($wpdb->postmeta.meta_key = 'my_meta_box_check' AND $wpdb->postmeta.meta_value = 'off')";
   return $where;
}
© www.soinside.com 2019 - 2024. All rights reserved.