A post without a top level comment means it doesn’t have any comments at all. You can’t query posts without comments unless you have a custom $wpdb
query.
You can however run a check against the post to see if it has comments and then display it using has_comments()
if the $wp_query object is set.
You can read more about the has comments function here: http://codex.wordpress.org/Function_Reference/have_comments
You could do a custom query like this:
if(!empty($_GET['no_comments'])){
global $wpdb;
$post_ids= $wpdb->get_col( $wpdb->prepare( "
SELECT ID FROM {$wpdb->posts}
WHERE comment_count = %d AND post_type = %s", 0, 'films') );
$args = array(
'post_type' => 'films',
'post__in' => $post_ids
);
} else {
$args = array(
'post_type' => 'films'
);
}
This assumes you are using a form to choose whether or not to show posts with comments.
Related Posts:
- Want to filter only parent post in admin area
- Setting proper query for multiple custom admin filters
- Genesis filterable portfolio isotope [closed]
- Filtering WP_Query
- creat filter with wp_query
- A method for ordering mixed dates in search result loop (theory only, no actual code)
- How can I made custom taxonomies relationship?
- Filter Posts from the Main Query
- Can I display custom post types in home.php or need page template?
- conditional filter
- WP Admin Dropdown List Filter for custom (ACF) field on custom post type(s)
- Filter posts by their related field’s custom field
- How to use multiple orderby conditions on query search results? (orderby one post type, relevance)
- Output all terms slugs for a loop filter
- How can i skip same post from taxonomy term?
- WP_Query | ‘post_type’ doesn’t work
- How to connect two custom post types with nested loops
- Filter by custom taxonomy slug on a custom post type
- Custom Post type and Custom Field WP_Query
- wpdb custom post_type problem
- Pagination on category page with custom post types
- Display multiple custom post types and sort them chronological by one of their fields
- Using DISTINCT in wp_query
- Using global $post; to get featured image for custom post via WP_Query
- Query custom post type in the loop
- custom comments on specific post type
- How to add pagination to wp_query [duplicate]
- WooCommerce product search titles only
- Related posts in all categories of current post (custom post types)
- Taxonomy Archive: Display only one post per term from separate custom taxonomy
- Loop through Custom Post Type, and then show children within each iteration
- Insert data on comment post
- Why does querying on post_tags (which has been applied to custom post types) only return posts?
- Sorting multiple custom post types without a meta key/value pair by sort order
- Including Custom Meta with posts_where query
- Very Slow Page – How to Optimize # of Queries?
- orderby in custom WP Query does not work
- Pagination : How to remove /page/x/ after a ‘POST’ action on a form returning to page 1
- How to detect filter in URL in Category page?
- Can I create a loop with multiple post types and specify different $args for each post type?
- How to show CPTs in term archive
- Query custom post type by category slug
- Custom query to filter posts that have current post as a taxonomy [closed]
- Combining sorted and random CPT
- How to add post_type=value when editing that post type in the WordPress admin?
- Why is conditionally loading a custom plugin’s code only on a specific custom post type causing the site content to disappear?
- Display CPT posts based on specific taxonomy
- Can’t query tag and post_type at the same time
- How to query custom post types posts filtered by multiple custom taxonomies through a form selection
- shortcode to show custom post types by category
- Unable to retrieve any posts of CPT in wp-admin
- WP_Query: include custom post type only with specific meta value
- Pagination on a custom post type loop
- showing custom post types of a certain category only
- WP_Query orderby modified to include custom meta changes
- WordPress custom loop filter by meta_key and value with serialize data
- Returning a list of custom post types excluding those without a specific meta_value
- query private custom post type
- Display custom post type from dynamic custom field
- Query/list all terms and their custom post count
- Append date to custom post type url slug
- Linking to the most recent post in a Custom Post Type
- How to make sure content doesn’t display if selection is empty
- Filtering WP_Query Dynamically on the Front-End
- Show one item per category of a custom post type
- Why get_posts() not returning only selected category posts from Custom Post Type?
- Storing posts from query and accessing later via AJAX call
- Two near-identical custom field types – one works, the other doesn’t . What can cause this?
- Archive for custom taxonomy lists all posts instead of current taxonomy
- Query custom post type with tags
- wp_query check if integer exists in custom field’s array
- convert custom query to wp_query
- Wrong request query on cpt and tax
- How can I see a list of my Custom Post Types of the last term I was in?
- get_comments not working on custom post types
- Previous/Next Link by Meta Value in CPT
- Show custom post type filtered by category
- Randomize Posts. Skip the first post in ascending order
- Creating a navigation menu of all posts of a custom post type and their children posts?
- Get custom taxonomies from multiple posts
- Pagination for Custom Taxonomy Page [duplicate]
- Custom Post Type Set Comments ON by default without show METABOX
- Search / Filter posts on Title/Content OR Tags
- Pagination on with query_posts in custom post type template
- Wp_query: sort by PHP variable
- WP_Query most viewed posts, in multiple Post Types, last 30 days, excluding a specific taxonomy term
- Custom-Posttype & Custom Taxonomy WP_Query
- Crafting WP_Query array, sort by date
- Custom loop with multiple taxonomy queries
- Return one unique custom post type result when it shares a custom taxonomy in WP_QUERY?
- Displaying custom taxonomy in the admin list of a custom post type
- Converting the_content string to an array?
- forming WP_Query for posts of all post types but from specific categories
- How can I run this code once so that my generated post title doesn’t keep changing on publish/update?
- Get latest 3 posts from multiple CPT in one query
- Loop to fetch 3 post_thumbnail instances from 3 most recent custom post types named “portfolio”
- filter custom post type by meta key in dashboard
- Display upcoming Events for next 7 Days
- Categories of custom taxonomy don’t show any posts
- Isotope Filtering with Bootstrap Tabs – Custom Post Type Query Loop in each Tab (Have to click twice to filter)