Basically, you can’t do it in a single SQL query. You need two.
You don’t have to make direct queries though, since you can use get_post() and get_post_custom().
Related Posts:
- Export WordPress Posts and Meta Information in CSV format
- post__in for get_posts with a dynamic array
- Using $wpdb to query posts with meta value containing current post_id
- how to get permalink using sql
- WP_Query to work with custom view
- Replace Main Query With Custom Query
- Use Cron to modify posts via sql
- Sql syntax error
- How do I batch create revisions of all posts?
- How do I find which articles are missing a featured image in The WordPress database?
- Bulk update post slugs through database
- Get the most repeated post contents from a search?
- Multiples Empty Posts were created and cannot delete them
- Delete WordPress posts from URL list sql query
- SQL query to retrieve all the records that have not indicated category
- How to verify wp user password by sql query in wp? [closed]
- Get ALL post ID’s export list (Only id’s. Php or sql not important )
- How to do set post permalinks using 6 digit random unique function?
- Using $wpdb to fetch posts with meta data
- Creating a post from data returned from HTML form
- wp_posts table: safely remove unused columns to save database storage
- Why Query is returning empty array?
- WordPress website loads more posts than expected
- SQL Command for restoring trashed comments
- meta_value timestamp older than now
- Displaying post excerpt using wpdb query
- How to Assign / Move all Deleted post to a category
- Migrate posts from category and sub-category via SQL
- Retrieving posts by their date and category
- remove all custom post created
- SQL Bulk Move old posts by one author to another category
- Export all posts to import as product items
- How can I get posts from 9/13/11 to today with SQL? [closed]
- query for filtering published posts?
- How to save template data into wp_post table (post_content column)
- Change published date and time using SQL query for page in every 5 hour
- SQL DELETE multiple post_meta on single and multi-sites
- Bulk find & replace on WordPress posts/pages (minus image paths)
- SQL query: select duplicate posts – but using duplicate meta [duplicate]
- Top tags with minimum number of posts
- WordPress MySQL Search and replace with wildcard?
- Using a meta_value or postdate to to query and orderby
- insert post fails after multiple postings
- wp_insert_post not inserting post
- Adding wordpress posts using phpmyadmin
- How to run select query of post with category and tags?
- I am not getting result from php function that is json encoded
- Export Posts with specific custom fields by sql
- Query to get data of a post, if in category?
- Can’t create posts with WP DB Abstraction Plugin
- Save/retrieve form data best practises for theme development
- SQL query to remove first image in all posts
- Delete junk text from all the post using my sql command
- Special Query: Title, Terms, Content – %LIKE%
- If meta_key exists then don’t select this post?
- The page that displays Posts on homepage
- WP_Query post_tilte search in posts table
- Change permalinks in posts via SQL
- Batch Scanning and Deleting Empty WordPress Posts
- How to get a list of all posts and their categories?
- How to speed up WP_Posts_List_Table __construct() Query on a wordpress website with over 1 million posts?
- SQL phpmyadmin remove posts from cat id exclude condition
- Wp forms wpforms()->entry->update not working on page refresh
- Get WordPress post content by post id
- Get page ID of page that is set as the posts page
- How do you properly prepare a %LIKE% SQL statement?
- Get Posts Under Custom Taxonomy
- How to limit the number of posts that WP_Query gets?
- Stop WordPress Wrapping Images In A “P” Tag
- When is the ‘post_content_filtered’ column in database cleared by WordPress?
- Turn a URL into an Attachment / Post ID
- GET the excerpt by ID
- Stop WordPress automatically adding tags to post content
- WPDB Insert or if exists Update
- Determine if page is the Posts Page
- How to get ‘post_content’ without stripping tags?
- How to add an admin notice upon post save/update
- Print Current Post Index number within Loop
- Should we trust the post globals?
- Optimize post insert and delete for bulk operations?
- Get the Current Page Number
- How do you add thumbnail support for custom post types?
- How to mark every 3rd post
- Change Posts per page count
- Keep featured content post in homepage with original order
- How to display related posts from same category?
- Can posts have parents?
- Is there a action hook for the “Empty Trash” button?
- How to end the excerpt with a sentence rather than a word?
- How do I check if I linked to a post before I delete it?
- How to change the case of all post titles to “Title Case”
- Appending content with broken in 4.4
- How to get posts published between a date and today?
- ZIP up all images displayed in a [gallery] and offer as download link
- How to detect single.php (but not single-portfolio.php)?
- How to check if post meta key exists or not in wordpress database
- How to remove a column from the Posts page
- removing inline styles from wp-caption div
- What is the use of to_ping and pinged column?
- How to use “Add link” pop up for a WordPress widget