Is this happening if you remove the pre_get_posts
hook?
Either way, you can try wrapping the code in a conditional.
while (have_posts() ) : the_post();
if ( 0 < intval( the_ID() ) {
...
}
endwhile;
This is not quite as good as limiting the number of records returned by the query but it doesn’t hurt to validate as you go along anyways.
Related Posts:
- Adding custom tables to WordPress
- Received nothing after executing AJAX post function
- Assign External Database Queries to Global Variables and Make Them Accessible
- How to import a custom MySQL DB table into a WordPress custom post type
- I’m trying to create a custom version of the wp_list_authors function that includes custom post types
- How can I remove the “Add New” button in my custom post type?
- Get Custom Taxonomy ID within loop
- Get custom post type by category in a page template
- Categories under custom post types doesn’t show properly
- how to use two permalinks for one custom post type
- Clean URL permalink for custom post type
- WordPress is executing URL in code when called via wp_mail()
- How to append element after thumbnail
- Query to change custom post type with specific category
- Order WordPress Custom Taxonomy Pages & Pagination Not Working
- Using several custom fields as custom post title
- Custom Post Type without an archive page
- Return the thumbnail meta data for getter and setter
- Pagination for custom php code
- What’s the difference between same wp functions get_posts(); functions in different form?
- how to check if custom post type column already exists?
- Custom Post-Type not in admin menu
- Page vs Custom Post Types Differences/Issues
- Troubles with saving metabox
- Can I list a custom post type within another custom post type in the admin area?
- I would like to have different styles for my posts based on the content of each post
- Checking if Post Title is Unique as Loop Criteria
- Set URL link to featured image of custom post type
- AJAX load more for different custom post type loops
- On update or create post redirect to current post position in list
- Changing wordpress publication date to ACF date and time picker date not working
- How do I add a custom screen for a custom post type to be called from custom post row action?
- WordPress custom post type permalink rewrite shows page not found
- How to display custom WP menus?
- Custom post type editor with dynamic selects, one drop down populating a second second drop down not working
- Display latest x posts from all categories in Custom Post Type/Taxonomy
- Displaying custom field according to date
- Add additional field to custom post_type
- categories should be available across all custom post types
- Including all post id’s of a custom post type into an array
- Understanding Post Formats/Custom Post types Etc
- custom post for slider
- Using wp_query to modify the loop in index.php for a CPT
- Custom Post not working as expected
- Show current custom taxonomy
- finding and using post type fields in WordPress
- After creating Custom post type by user delete old one
- Create short URL with auto 301 redirect
- get_post_types() can’t get some of my post type
- Creating shortcode id for custom post types
- How to add new post using a form to categories when categories are using as menu
- Different post title, keywords and description
- post_content is stripping HTML when adding a new post? [closed]
- Querying a custom post type, but not show duplicates
- Different column width in 2 rows with bootstrap and custom post types-different classes needed
- $wpdb is queried but results don’t show
- Menu’s breaking, now showing all page links on site
- Creating on-page options for Custom Post Type
- Post type Echo code is repeating on homepage
- How can I increase the post count for custom post types only?
- How do I call the custom Post Type name and permanent link to my php file?
- How to get the custom field value using SQL query
- Fetch data of 2 relational Custom Post in WordPress
- Is it possible to hide nav menu items only when they are page titles (on specific templates) but not on the dashboard?
- Grouping custom wordpress post types by acf value
- Title and URL Error in Breadcrumb Navigation for Custom Post Types
- I’m having trouble with Related Product “tax_query” ‘terms’ value
- Assigning categories to custom post types via a front-end form; only works for native post type
- Show code dependant on CPT & category
- Adding featured image to a new post using front-end form?
- WordPress – display relationship between blog posts and custom posts
- when looping through custom post data not appearing
- Getting a Post ID to show its content in a Popup
- Custom sorting in post columns by ACF Pro Select Field
- Load info from customposttype into template page
- wp_post_delete is deleting all offices
- Custom Post Type has wrong label and is not found when called by a loop
- Disable Sidebar on certain pages
- current-post-parent for custom post type
- Show parent category and subcategory once in while loop
- Having issue on Loading Meta Data From CSV to CPT
- Rewrite URL of Specific Post of Custom Type
- How to get the posts that my following users are liked?
- Display related post content and custom field content
- Custom 404 redirect for a luddite
- Post that populates itself (almost) automatically using data from imported excel file
- Show tags of custom post types in WordPress
- can’t see categories in appearance-menu-categories
- Meta Box not being added in plugin
- Custom post order when using OR relation
- wordpress form processing to custom post type not working
- WordPress custom field images not getting inserted into array
- Meta-Box to add multiple items one at a time and on publish save all
- Values inside a custom field to determine which category posts to display
- Posts without featured image using other post’s featured image
- Return all wordpress custom posts in specific multidimensional array
- Building a List of Posts grouped by custom taxonomy as the section header only to be displayed if at least one post is in that tax
- Problem with a query in custom posts
- Custom Portfolio String
- Create a WordPress Database query to find users who purchased specific product through WooCommerce [closed]