目前无法对此进行测试,但请尝试以下方法。在所有帖子中搜索您的帖子名称(特殊标题),获取ID,然后利用post__not_in
在中排除这些IDget_posts
.
function getAllPostIdsTest(){
global $wpdb;
$excluded_posts = $wpdb->get_results("SELECT id FROM " . $wpdb->posts . " WHERE `post_title` LIKE \'%"Special title"%\' && `post_type` = \'post_test\'");
$args = array(
\'post_type\' => \'post_test\',
\'posts_per_page\' => -1,
\'meta_query\' => array(
array(
\'key\' => \'post_test_safe\',
\'value\' => 1,
\'compare\' => \'=\'
),
),
\'fields\' => \'ids\',
\'orderby\' => \'asc\',
\'post__not_in\' => $excluded_posts
);
$ids = get_posts( $args );
send_json($ids);
}
编辑:
post__not_in
需要一个简单的ID数组,ex//
array(1,2,3,4)