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?
- WordPress Post Query Using Custom native MySQL like St_Distance_Sphere
- Keep featured content post in homepage with original order
- How to get posts published between a date and today?
- How to show related posts by category
- the_author() returns empty string
- MySQL Query to Retrieve Category from wp_posts
- Display all posts from specific categories on a page
- SQL Query for getting all posts in their latest revised state
- How to exclude latest x posts from a paginated query?
- post__in for get_posts with a dynamic array
- Search & Remove Specific Shortcode From All Posts
- Display content from a specific category
- Manually delete post from database
- How to display posts by current user/author in a custom page template?
- Using $wpdb to query posts with meta value containing current post_id
- post_name empty after wp_insert_post
- Query posts distinct authors
- WP_Query to work with custom view
- How to get previous 10 days post from a specific date – WP Query
- Number of posts per page setting is not working?
- WordPress Posts Out Of Order after 3.1 Update
- How to force update all posts after import
- Query only Posts from Both of Two Category?
- Insert custom div between posts
- Can’t show comments count per post outside loop
- Only display posts with comments
- Order post by year DESC and month ASC
- WordPress get posts by date without query_posts
- How to Display Post View Count
- Replace Main Query With Custom Query
- Different amount of posts on homepage than paged pages
- Query All users that has post
- Featured Posts for Category Pages
- get posts and postmetas in assoc array
- Can’t publish new posts
- Cannot Update A Post, 404 Error
- Function to show random posts from a category
- Hiding posts in a list from specified categories
- How do I batch create revisions of all posts?
- How would I get 1 latest post from a query for 5 posts?
- Filter Posts By Tag
- Manually removing revision post types
- Can I set and show “important” post in my blog?
- Exclude posts with empty post_content in wp_query
- Reset/Reorder posts ID in the MySQL wp_posts table
- How do I find which articles are missing a featured image in The WordPress database?
- Improving WP_Query for performance when random posts are ordered
- Create dropdown list post
- I would like to give special promotion for the first 100 posts in my blog? Can anyone tell me how to do that?
- previewing my posts on static page?
- Exclude newest post from category X but show rest
- Tags to Post-ID mysql query. Tag Search
- Reset Popular post query?
- Can’t get wp_insert_post to work
- Inserting custom data to the_post() during loop
- How To Get Posts With A Specific Word
- Why WP_Query(‘showposts=5’) shows only 1 post?
- is there a way to show the the post title after the image?
- Display posts with tag that matches current post title
- Why is querying posts messing up my pages?
- wp_insert_post – duration
- Display all posts that were published before full post on single.php
- Category Foreach keeps looping?
- Blog post per page setting conflicting with custom WP_Query?
- How to exclude latest x posts from a paginated query?
- Two loops, one AJAX loop, exclude posts in first loop from second loop, loops are in different files
- How to do set post permalinks using 6 digit random unique function?
- Get user categories with most posts in it
- Random ajax load only works with posts_per_page set to -1
- MySql query to get posts with all meta and terms
- 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
- Multi row post list
- Custom order for Mysql array
- posts_per_page option limits the number of Gallery items
- List authors with the last post title and order by last post date
- How to make multiple sections in home pulling posts category wise?
- Query Posts by Custom Field
- How to Mysql select a list of posts with meta_values AND all relevant categories?
- Remove a shortcode from all WordPress posts
- How to order posts in an arbitrary order?
- What do these phpMyAdmin errors mean on my WordPress databaes?
- Display Posts on Custom Page
- How to get posts from a current post’s month?
- Wrong post title displayed from loop
- What happens if I delete all the rows that represents a post revision from the posts table into WordPress database?
- Nested WP_Query breaking loop
- WordPress query_posts by tag doesn’t work anymore(?)
- While loop articles – if statement order
- do more action after I publish a post
- Retrieve only posts from a specific user in wp-admin/edit.php
- Conditionals if tags exist?
- Why Query is returning empty array?
- Delete post results in “Cannot delete or update a parent row: a foreign key constraint fails”
- WordPress website loads more posts than expected
- Get the amount of posts on a current page
- Posts – display all posts except a post by an ID