您需要一个附加参数meta_query
在WP_Query
参数。
$query_args = [
\'posts_per_page\' => -1,
\'s\' => esc_attr( $_POST[\'keyword\'] ),
\'post_type\' => \'visitor\',
\'meta_query\' => [
\'key\' => \'visitor-hide\',
\'value\' => \'yes\',
\'compare\' => \'!=\',
]
]
或者在类似您的情况下(按单个自定义字段查询):
$query_args = [
\'posts_per_page\' => -1,
\'s\' => esc_attr( $_POST[\'keyword\'] ),
\'post_type\' => \'visitor\',
\'key\' => \'visitor-hide\',
\'value\' => \'yes\',
\'compare\' => \'!=\',
]
有关自定义字段参数的详细信息,请参见
WP_Query
here.