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
- How to mark every 3rd post
- Is there a action hook for the “Empty Trash” button?
- Delete post with all files attached to it
- disable WP automatically inserted line breaks after an image
- Strategy for handling hierarchical pages with empty parent content
- How to merge two or more WordPress posts?
- Writing a view count with w3 total cache
- Utilising posts with various post types & categories?
- Prevent WordPress from giving each post a number
- Single.php Active Category Class
- WordPress Rest API – Get all posts based on post_meta on custom endpoint
- Link for the page archive for posts, like using custom post types with get_post_type_archive_link
- How to edit wordpress RSS feed to show post title only
- Search widget breaks when using multiple loops?
- Limit amount of results returned
- Remove image from post also removes photo from media library
- Require a featured image to publish post
- How to create multiple version of single post
- Create pretty permalink for a post knowing the permalink structure
- Syndicated Posts when Updated Lose HTML tags
- How to insert current date/time in the content of a post?
- How to change the title url on the edit post screen?
- jQuery inluclude still seems ncessary for script to work within post
- White Blank Page when Updating and Publishing Page/Post
- Full Width Main Post
- Plain permalinks not working!
- get_the_content_feed with paginated posts
- How to create large page
- How to get rid of shortcodes in post content once and for all
- Why is querying posts messing up my pages?
- How can I find out what items a user has purchased? [closed]
- Nothing Found error when creating new posts – how to correct this?
- Print all the tags from a custom post type Please
- WordPress Loop – Next 3 Posts
- Display multiple custom taxonomy values on single custom post types page?
- Underscores Theme Unit Testing – Catching Untitled Posts
- Encountering “Wrong nonce. Action prohibitied.” when trying to alter User Role and unable to Post via WP Admin
- Is Hfeed class for all pages needed