You can add this to the WHERE clause, just after your filter by post_date:
AND post_status = "publish"
Related Posts:
- wp_posts table: safely remove unused columns to save database storage
- Order posts alphabetically: how to set order=asc in mysql query?
- How to get posts published between a date and today?
- the_author() returns empty string
- MySQL Query to Retrieve Category from wp_posts
- SQL Query for getting all posts in their latest revised state
- post__in for get_posts with a dynamic array
- How to display posts by current user/author in a custom page template?
- post_name empty after wp_insert_post
- How to force update all posts after import
- Query only Posts from Both of Two Category?
- Insert custom div between posts
- Only display posts with comments
- How to Display Post View Count
- Different amount of posts on homepage than paged pages
- Query All users that has post
- get posts and postmetas in assoc array
- Can’t publish new posts
- How do I batch create revisions of all posts?
- How would I get 1 latest post from a query for 5 posts?
- Can I set and show “important” post in my blog?
- Exclude posts with empty post_content in wp_query
- How do I find which articles are missing a featured image in The WordPress database?
- previewing my posts on static page?
- Reset Popular post query?
- Can’t get wp_insert_post to work
- is there a way to show the the post title after the image?
- Display posts with tag that matches current post title
- wp_insert_post – duration
- Category Foreach keeps looping?
- Blog post per page setting conflicting with custom WP_Query?
- How to exclude latest x posts from a paginated query?
- Using $wpdb to fetch posts with meta data
- Display an author’s posts on his own author page
- Creating a post from data returned from HTML form
- How to make multiple sections in home pulling posts category wise?
- Query Posts by Custom Field
- Remove a shortcode from all WordPress posts
- How to get posts from a current post’s month?
- Wrong post title displayed from loop
- While loop articles – if statement order
- Conditionals if tags exist?
- Delete post results in “Cannot delete or update a parent row: a foreign key constraint fails”
- Get the amount of posts on a current page
- Posts – display all posts except a post by an ID
- Inner join overrides Advanced Custom Fields plugin’s get_field [closed]
- update image path with words starting uppercase to lowercase chars
- why the same code got different results when using query_posts in functions.php and index.php
- Archive template combined with post slider and regular posts
- How to get posts published on the latest date?
- How to only publish posts with image in it
- Post Filtering by GET URL parameters
- WP_Query: Show 10 posts in date order, first three random
- Get post by tag
- Random posts that always include a particular post?
- Need to change all links in page content but not in post content
- Can’t update WordPress Page if post_content is Empty
- Bootsrap carousel for post
- How to select particular month post from table and update the post status using MySQL?
- Retrieving posts by their date and category
- Echo the number of posts being displayed
- Exclude a category of posts in author template
- WordPress displays post on subcategory only
- Trying to query all posts in category 4
- Get posts from current category?
- get last post’s link with SQL query
- Change content off every sixth element
- How to save template data into wp_post table (post_content column)
- WP query taxonomy optimization
- get posts, run a custom query, and join the results
- Show posts from two specific category in WP_Query
- How to create loop of posts except post ID defined via ACF field
- Displaying all posts from other sites on the network on one site
- Multisite how to display merged posts from two sites and sort by latest date?
- How to show post views shortcode data for each post on Posts List Page?
- WordPress MySQL Search and replace with wildcard?
- How to display particular categorie’s post which associated to specific user?
- Add postmeta to all blog posts
- wp_insert_post not inserting post
- Dev and prod on the same database- dev version active for IOS
- Manipulate query to show specific post
- How to correctly escape data
- Blog posts not displaying on blog posts page
- Sort Events by Venue Title – Sort Post set by related post ids
- Get posts by category or author
- Sort / Filter Queries
- get “read more” with custom DB query like you would with WP Query
- Save/retrieve form data best practises for theme development
- How do I control the fallback query after the original query returned cero posts?
- SQL query to remove first image in all posts
- How to pass multiple checkbox values to wordpress query?
- Delete junk text from all the post using my sql command
- How to get all post titles starting with numbers and symbols?
- How to inject a post within a loop
- How to get alphabetic listing x other posts, based on first letter post?
- How to create a post based on data in a table?
- wp trim function not working
- Change from all posts to specific categories post on main page?
- query_posts different amount of posts per page [duplicate]
- Do I need to create a multisite for querying posts from multiple WordPress sites?