Try this (you may need to bootstrap WP by loading wp-load.php
, depending on where you put this code).
$args = array(
'post_type' => 'post',
'post_status' => 'publish',
//'posts_per_page' => -1 //uncomment this to get all posts
);
$query = new WP_Query($args);
while ( $query->have_posts() ) : $query->the_post();
$f = fopen(get_the_title() . '.txt', 'w');
$content="Title: " . get_the_title() . PHP_EOL;
$content .= 'Pub date: ' . get_the_date() . PHP_EOL;
$content .= 'Category: ';
foreach (get_the_category() as $cat) {
$content .= $cat->cat_name . ', ';
}
$content .= PHP_EOL . PHP_EOL;
$content .= get_the_content();
fwrite($f, $content);
fclose($f);
endwhile;
Keep in mind, if two posts have the same title, you’ll only get one text file.
Related Posts:
- How do I export my WordPress blog as a book? [closed]
- Is it possible to export WordPress from command line?
- Export specific menu [duplicate]
- Import posts with featured images
- How to Create Export/Import Functionality for Plugin
- Most Flawless Way To Transfer from Dev to Prod [duplicate]
- Problem: Create a cron job to export posts to a WordPress XML file on server
- How do I add paragraph tags to all of my posts after relying on wpauto?
- export csv functionality into my plugin
- Best practice to import/export specific pages and posts
- Export posts to csv with data from ACF custom fields
- Export a blog(not mine) as a PDF document
- export category and sub-category
- I am having trouble with article formatting when exporting/importing articles from the production to the development environments
- Export local WP install to live – help needed
- Moving wordpress site to subpage of another site
- 403 export error when exporting pages from multisite subfolder site
- Export Custom Report as CSV
- UTF8 Encoding problems when exporting posts
- How to give my database to a friend for duplication in a secure way [closed]
- How to assign name the WordPress export.xml file
- How can transfer get so large when exporting data (15-16MB to over 10GB)
- Export All Posts and Media to XML and/or Word
- Button to download export data WordPress in CSV file
- How to add a timestamp to the exported WXR filename?
- ExpressionEngine Export/Import Issues
- Get all post from table and put it in excel sheet
- How can I export Grunion Contact Form messages in an easily parsable format, e.g. CSV?
- Different way to export data from WP?
- export individual posts to text files or a single csv file
- How to export posts and keep html tags in the title
- Does doing an export moves all my posts or just a copy of it?
- wordpress export pretty permalinks and post excerpt export
- Best Way To Locate Offending WP Table
- How to export native WordPress events in a form useful to Events Calendar
- How to export custom post type posts based on date range
- Print string to text file
- How to extract text from a PDF? [closed]
- How do I find all files containing specific text on Linux?
- Editing legend (text) labels in ggplot
- XQuery data and text() function
- Export Pervasive to MySQL (C#)
- How do I export whole Unity project with all scenes?
- jQuery if div contains this text, replace that part of the text
- How to place a text next to the picture?
- Import / Export database with SQL Server Server Management Studio
- Why Is `Export Default Const` invalid?
- How to display text in pygame?
- How to wrap text in LaTeX tables?
- Where does this come from: -*- coding: utf-8 -*-
- CSS no text wrap
- How to remove spaces from a string using JavaScript?
- Vertical Text Direction
- Difference between VARCHAR and TEXT in MySQL
- How to read a text file into a list or an array with Python
- How can I export data to an Excel file
- How to properly export an ES6 class in Node 4?
- How can I create a text input box with Pygame?
- Indent starting from the second line of a paragraph with CSS
- How can I replace text with CSS?
- align text center with android
- PCI\VEN_10EC&DEV_522A&SUBSYS_837D103C&REV_01
- Do a “git export” (like “svn export”)?
- -bash: export: `=’: not a valid identifier
- Text border using css (border around text)
- How to replace multiple substrings of a string?
- How to easily print ascii-art text?
- Making text background transparent but not text itself
- strange text before my header wordpress
- How to place Text and an Image next to each other in HTML?
- How do you change text to bold in Android?
- How to split large text file in windows?
- Setting a max character length in CSS
- Align text to the bottom of a div
- Remove Project from Android Studio
- Text wrapping around a div
- mysqlworkbench giving version error on exporting database
- How can I change the text color with jQuery?
- How to set text color for my d3 chart title?
- Reading local text file into a JavaScript array
- How to export JavaScript array info to csv (on client side)?
- How can I align text directly beneath an image?
- How to Read from a Text File, Character by Character in C++
- Where does the Media Library live in the database?
- Stop WordPress automatically adding tags to post content
- Failed to import Media
- can I add a custom format to the format option in the text panel?
- How to retrieve text only from wp_content() not from wp_excerpt()?
- How to export and import taxonomies (category, tag and/or custom taxonomy) and their terms
- How to Create Editable Blocks of Text for the Homepage?
- Plugin API for easy admin list table generation, handling & exporting of MySQL tables?
- How to export comments in WordPress?
- I want to develop locally with Multisite, then migrate each site to separate remote WP installs
- WP_User_Query and non-unique usermeta data
- How To Export/Import WordPress (MySQL) Database Properly Via Command-Line?
- Is it possible to “freeze” a WordPress blog?
- WordPress Theme Options Import/Export
- Export navigation menu
- Problem in wordpress with “-“
- One Click demo content installation feature in WordPress theme options panel