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?
- Keep featured content post in homepage with original order
- How to show related posts by category
- Display all posts from specific categories on a page
- How to exclude latest x posts from a paginated query?
- Search & Remove Specific Shortcode From All Posts
- Display content from a specific category
- Using $wpdb to query posts with meta value containing current post_id
- WP_Query to work with custom view
- Number of posts per page setting is not working?
- WordPress Posts Out Of Order after 3.1 Update
- Order post by year DESC and month ASC
- WordPress get posts by date without query_posts
- Replace Main Query With Custom Query
- Featured Posts for Category Pages
- Cannot Update A Post, 404 Error
- Function to show random posts from a category
- Hiding posts in a list from specified categories
- Manually removing revision post types
- 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?
- Tags to Post-ID mysql query. Tag Search
- 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?
- Display all posts that were published before full post on single.php
- Two loops, one AJAX loop, exclude posts in first loop from second loop, loops are in different files
- 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
- 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 Mysql select a list of posts with meta_values AND all relevant categories?
- What do these phpMyAdmin errors mean on my WordPress databaes?
- 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(?)
- do more action after I publish a post
- Retrieve only posts from a specific user in wp-admin/edit.php
- Why Query is returning empty array?
- meta_value timestamp older than now
- $wpdb returns duplicate posts
- Displaying post excerpt using wpdb query
- Display Posts with template on a Page
- Query for first 3 posts to change the look and feel
- Shortcode with ‘year’ parameter
- On what hook can I get the queried object’s final state?
- How to give classname to post if post has no content?
- How to use mysql LIKE with wpdb?
- Get the most recently modified post date of most recently modified post
- Queries take 120+ seconds on my large WordPress site
- Database hacked – random posts are modified
- WordPress post filter menu
- Restore woocommerce orders
- How do post IDs work in WordPress?
- WordPress query portfolio posts
- How to get posts ordered by using their categories?
- WP_Query articles order by offset in collumns
- Display 3 posts with different HTML markup using a loop
- Getting posts from some categories plus some individual posts
- How to assign a post to a post parrent?
- get parent fields title, content excerpt etc
- MySQL: Possible to replace all of wp_posts.post_content(id#) via UPDATE + REPLACE + SELECT?
- AWS usage queries
- Move position in post list for a custom checkbox column
- How to merge the content of posts that have the same title?
- Query to fetch custom taxonomy along with post title
- How to fetch courses in all languages in WordPress?
- Mysql update menu_order problem
- Bulk find & replace on WordPress posts/pages (minus image paths)
- How can I use query_posts to loop through posts and construct my own content?
- ‘posts’ table should not store the absolute image path
- Assign a day of the week to post, e.g: Assign Monday to post and have it only appear when the day is Monday
- load post data into mysql
- Show 5 posts and than 3 posts offset with pagination
- wp_query args with relation
- Querying posts from current category, using a variable as array argument
- Use special template for the first post in the loop
- Need help writing loop to display posts by categories in separate divs
- Modify WordPress loop after it has been run
- Query post category & remove any post id
- show latest authors blog post
- Converting Posts to Pages
- How to get only current images of a post
- Ordering posts alphabetically by meta keys and title
- Why I have this strange behavior when I try to exlude the featured post from posts visualization?
- How to change the publishing date of each posts?
- Remove duplicated posts in the loop if post has more than one category
- How to limit the number of results for all query_posts on mysite
- wp_query select if have comments
- How to limit post query to only return a total count of items with certain post statuses?
- Not displaying any articles on a custom made file
- If meta_key exists then don’t select this post?
- Sort Posts Alphabetically Based on Specific Category (Divi)
- WP_Query post_tilte search in posts table
- How to manually delete post from database without causing conflicts?
- Why does ‘get_the_ID’ work outside of the loop?