If you want to export the data to a CSV or JSON file directly from the SQL query, you can use the MySQL INTO OUTFILE
clause.
SELECT wpd9_posts.post_title, GROUP_CONCAT(wpd9_terms.name) AS categories
FROM wpd9_posts
LEFT JOIN wpd9_term_relationships ON (wpd9_posts.ID = wpd9_term_relationships.object_id)
LEFT JOIN wpd9_term_taxonomy ON (wpd9_term_relationships.term_taxonomy_id = wpd9_term_taxonomy.term_taxonomy_id)
LEFT JOIN wpd9_terms ON (wpd9_term_taxonomy.term_id = wpd9_terms.term_id)
WHERE wpd9_posts.post_type="post"
AND wpd9_posts.post_status="publish"
GROUP BY wpd9_posts.ID
INTO OUTFILE '/path/to/export/posts_categories.csv'
FIELDS TERMINATED BY ',' ENCLOSED BY '"' LINES TERMINATED BY '\n';
Related Posts:
- How do I find which articles are missing a featured image in The WordPress database?
- Multiples Empty Posts were created and cannot delete them
- Extracting post categories
- How to Assign / Move all Deleted post to a category
- Migrate posts from category and sub-category via SQL
- Display post number by category
- SQL Bulk Move old posts by one author to another category
- exclude particular category in api
- Bulk find & replace on WordPress posts/pages (minus image paths)
- Is there a way to save different data when USER interacts with the same POST?
- More Than 50K Categories and WordPress Admin Panel Stop Showing Categories and Posts
- How to run select query of post with category and tags?
- Surrogate ID for posts, is there an alternative field in the posts table?
- How to make category for word post_content
- Change permalinks in posts via SQL
- How can i limit the number of posts created per category?
- How to Restrict Previous & Next Post Link to Posts of Same Category?
- Pulling in post category and children within category
- WordPress custom Query for Posts in Category display posts multiple times
- Post categories to pages
- Get user categories with most posts in it
- Post page to display specific category
- Get Posts Under Custom Taxonomy
- Transferring WordPress Database – Serialised data
- Get attachments for posts that belongs to a specific category
- Prevent additional top level categories but allow more children
- Need help with category listing!
- Emojis replaced by ‘?’ automatically
- Prepending %category% onto default posts fails
- List all categories with featured image from post?
- How to disable WordPress blog folder
- Categories list into registration form
- WordPress Local And Live Site
- WP_Query: Mixing category__in and tag__in together
- If in_category not working for multiple single.php pages
- How can I setup a relationship using categories in WordPress?
- WordPress Multisite – Create Default Post and New Category On New Site Install
- how to show single post in a custom template
- Can’t update old posts 3.5.2
- Using ajax on editing a category edit page?
- Related posts by category not working right
- How to list recent posts in a wp nav menu?
- Set Default Category to Username
- Disable sticky option for specific categories
- Dynamic dependent Dropdown lists for categories, sub-categories and posts
- How can I hide tags on a child-category page, if that tag has not been used?
- date issue with category post retrival
- Copy post to separate database with “add_action(….)”
- Listing Specific Categories from Current Post with Depth
- How to make multiple sections in home pulling posts category wise?
- How to display two blog categories as separate sections on one page?
- When open add new post or page WordPress add post with ID=0 continuously [closed]
- wp_posts table: safely remove unused columns to save database storage
- How to make the first post in the loop be styled like a “new / featured” post?
- Anyone know why wordpress converts some html entities to their numeric equivalents?
- How to Mysql select a list of posts with meta_values AND all relevant categories?
- Remove a shortcode from all WordPress posts
- Display post category in foreach loop
- Single.php – Get Current Parent Category
- How do I stop the loop from repeating in my category template?
- get_the_category listing in hierarchial order
- What do these phpMyAdmin errors mean on my WordPress databaes?
- Is it possible to add/tick a category to a post when it is created?
- Excluding posts not working
- Hide posts belongs to few categories in homepage
- What happens if I delete all the rows that represents a post revision from the posts table into WordPress database?
- why does wordpress ignore the post args?
- post category in wp_insert_post
- Limit the number of posts a category can have – newest post goes in, oldest one drops out, possible? plugin?
- why there are so many posts whoes post_type is revision? will these records waste too much database space?
- How to get subcategories from category slug?
- Remove current category from post but display all others
- How show categories in admin and get that selected to show posts in index
- Delete all drafts?
- WordPress website loads more posts than expected
- Is it possible to use WP_Query to only pull posts with attachments?
- SQL Command for restoring trashed comments
- Showing categories and subcategories with posts
- Change default category when I publish a post
- store posts_id of category into a varable?
- Get posts and include taxonomy term
- Why my wp_posts data is so huge?
- Change post-slug using wordpress API? Change permalink of a post using php / jquery?
- How to display two random-post sections that are each under their own category
- How can you display all sibling categories to a post?
- Loop doesn’t exclude the specified category in home page
- Display posts of specific category term
- Add field to user meta table in database when link is clicked
- Widget that shows categories with posts numbers
- How to create a sub post?
- Post Image not displaying in category view
- How do I show posts from another wordpress installation?
- How safe is it to delete old posts edits to save database space?
- get posts from Custom Post Type & Category
- Category page when using static front page
- Latest posts by category — how to exclude current post?
- How do I include the category next to the title of a post?
- Relative number of post in category
- How to create a “latest news” page showing a list of posts from blog category
- WordPress bulk category select when publishing post