WP_Query get posts where post_name is empty

You can try this: $args = array ( ‘post_type’ => ‘books’, ‘name’ => ”, ‘post_status’ => array(‘publish, draft’), ‘posts_per_page’ => -1, ‘meta_query’ => array( array( ‘key’ => ‘book_isbn_id’, ‘value’ => ‘dummy’, ‘compare’ => ‘NOT EXISTS’, ‘type’ => ‘NUMERIC’, ), ), ); add_filter( ‘posts_where’, ‘custom_posts_where’ ); $query = new WP_Query( $args ); echo $query->request; where function … Read more

Restrict a filter to a custom post type. Am I doing this right?

I think you’re looking for the “conditional” get_post_type. In your case it would be: function orderby_post_title_int( $orderby, $query ) { if ( ‘chart’ == get_post_type() ) { return ‘(wp_posts.post_title+0) ASC’; } return $orderby; } Or you could insert the conditional in your original function, which you know was working? (Note if this is a custom … Read more