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 Change Order of Posts in Admin?
- Multipart/formatted MySQL query problem
- Categories box not showing on post edit pages
- Removing the title attribute from links in the post content
- Custom function for “Submit for Review” hook
- how load content as pop-up using ajax
- Improving WP_Query for performance when random posts are ordered
- How to make the post summary taller?
- Why content_arr[‘extended’] removes paragraph tags?
- Getting index.php instead single.php for displaying posts
- Changing Permalinks for Default Post type to reflect navigation
- It is possible to add extra button under the ‘publish’ button in the post of wordpress? and how?
- 404 error on default post type and default taxonomy fronted page
- How i can limit period of post publication?
- Display post changelog in post
- All Posts Linking to Author Posts directly
- search blog posts by author first name and or last name
- Make loop inside slider divisible [closed]
- How to add convenient buttons for new custom post statuses
- Database hacked – random posts are modified
- Display value of custom field at the beginning of a post
- How to display post list in a table layout (multiple queries in single loop)
- Post is in descendant category not working in home.php
- How to show 3 most recent/viewed posts in a special tiles on home page using wordpress?
- Get content from WordPress posts in Boostrap modal window – Javascript side?
- How to assign a post to a post parrent?
- Bulk update published posts date randomly using wp-cli?
- How to insert custom text after H1 to all my blog posts?
- Sync All Post Type Tag
- how to redirect page after delete post inside a post page?
- Permalink base only for posts
- Custom fields in normal posts
- Modify WordPress loop after it has been run
- How to get next_posts_link working with a customised page
- Loop doesn’t display posts. It displays a link to the home page instead
- Custom Post Type Pagination 404 Error (if paged>=2) [duplicate]
- Show all posts in category
- Creating a new Sortable Column in WordPress Admin
- How can add custom commands in post-new.php in wordpress
- Filter/Sort Post Form On Taxonomy page
- Display post by select it from a dropdown menu