Unable to test this at the moment, but try something along these lines. Search all posts for your Post Name (Special title), grabbing the ID’s, then utilize post__not_in
to exclude those IDs in get_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);
}
Edit: post__not_in
is expecting a simple array of ID’s, ex// array(1,2,3,4)