Tool used to export all Wordpress Posts & Assets into Markdown. While exporting this has the ability to:
- Create Markdown Files in Data/Collections Directory
- Find Metadata
- Map Metadata
- Metadata to Front Matter
- Front Matter Defaults
- Find Images
- Add only Used Images to specified Assets Directory
- Convert Image URLs
- Find HREF URLs
- Replace HREF URLs
- Find Shortcodes
- Convert Shortcodes to new Static Site Generator Tags
- Shortcodes Preview / Seperate File with Shortcodes
- Config Yaml File Autmatic Setup
- Permalink Setup based on WP Setup
This should only be added to local instance of a Wordpress site. In the sites active theme folder, add the WPMarkdown
folder then at the bottom of the themes functions.php
file add:
/**
* WPMarkdown
*
*/
include_once 'WPMarkdown/_bootstrap.php';
In the config.php
file, to initiate build:
- Instantiate an instance of the
WPMardown
class - Set custom properties to specify the custom build
- Run the class build method
- Login to the local instance of the Wordpress Admin, this will fire the build in the
WPMarkdown
folder.
/**
* Configuration Settings
*/
$markdown = new WPMarkdown();
# $markdown->postTypes = array('post');
# $markdown->metaExclude = array('id', 'slug', 'collection', '_yoast_wpseo_content_score');
# $markdown->metaMapping = array('sub_navigation' => 'sticky_navigation');
# $markdown->metaDefaults = array('layout' => 'default', 'boss' => 'ER');
# $markdown->buildDir = 'build_10';
# $markdown->fileType = '.md';
# $markdown->fmClean = false;
# $markdown->shortcodeConvert = 'jekyll';
# $markdown->shortcodePreview = true;
# $markdown->paragraphTags = true;
# $markdown->shortcodeFile = true;
# $markdown->buildUploads = 'src';
# $markdown->status = 'draft';
# $markdown->limit = 50;
# $markdown->offset = 51;
# $markdown->buildCollectionsDir = '_cpts';
# $markdown->imagePrefixReplace = array('https://bestcolleges.com', 'http://www.bestcolleges.com');
# $markdown->imagePrefix = 'default';
# $markdown->urlPrefixReplace = array('https://bestcolleges.com', 'http://www.bestcolleges.com', 'http://uwaterloo.ca');
# $markdown->urlPrefix = 'https://www.cloudinary.com/uploads/';
$markdown->build();
$markdown->postTypes = array('post');
Optional. This will SQL query only the Post
post type on the site, you may specific any Custom Post Type you'd like. Otherwise, if this property isn't include will query all post types on the site.
$markdown->status = 'draft';
Optional. Default: publish This will SQL query only the draft status posts.
$markdown->limit = 5;
Optional. Limit the amount of post queried, good for batch parsing if needed.
$markdown->offset = 6;
Optional. Offset the amount of post queried, good for batch parsing if needed.
$markdown->fmClean = false;
Optional. Default: true This removes any Metadata from displaying in the Front Matter if value is empty. Otherwise, it'll show all Metadata attached to Post.
$markdown->paragraphTags = true;
Optional. Default: false Add WPAutoP to content.
$markdown->metaExclude = array('id', 'slug', 'collection', '_yoast_wpseo_content_score');
Optional. Exclude certain Metadata from displaying in the Front Matter.
$markdown->metaMapping = array('sub_navigation' => 'sticky_navigation');
Optional. Defaults: yoast_wpseo_metadesc = description, wp_page_template = layout, yoast_wpseo_title = title Rename Metadata to display correctly/differently in Front Matter keys.
$markdown->metaDefaults = array('layout' => 'default', 'boss' => 'ER');
Optional. Set default Metadata to add it to the Front Matter key values pairing.
$markdown->buildDir = 'build_15';
Optional. Default: build Build folder to add the Post Type Markdown files, Config, Shortcodes & Assets.
$markdown->buildUploads = 'src';
Optional. Default: assets/uploads Build folder to add the Assets.
$markdown->buildCollectionsDir = '_data';
Optional. Default: collections Build folder to add the Post Type Markdown files.
$markdown->fileType = '.html';
Optional. Default: .md Change the Markdown files extension type.
$markdown->shortcodeConvert = 'jekyll';
Optional. Options: jekyll, more to come... Convert Wordpress Shortcodes to Static Generator Tags.
$markdown->shortcodeFile = true;
Optional. This adds the Shortcodes used throughout the site in a separate file called shortcodes.txt.
$markdown->shortcodePreview = true;
Optional. This adds the Shortcodes used on post beneath the Front Matter on the Markdown file.
$markdown->imagePrefixReplace = array('https://bestcolleges.com', 'http://www.bestcolleges.com');
Optional. In addition to the WP Home URL and WP Uploads Directory, these specified URLs are also used to find and replace images that are prefixed.
$markdown->imagePrefix = 'default';
Optional. Default: default The way the assets directory is setup with the assets in the Markdown files. Default, will be the default setting Wordpress has on its backend(usually date based). Flat, is all assets into a flat directory, Markdown Files Updated. Custom URL, used for CDN image setup, add the url and they'll update in your Markdown files. Keep in mind, all the assets are added to the Build folder for you, do as you wish.
$markdown->urlPrefixReplace = array('https://bestcolleges.com', 'http://www.bestcolleges.com', 'http://uwaterloo.ca');
Optional. URL's to find and replace throughout the site, Markdown files will reflect this.
$markdown->urlPrefix = 'https://www.cloudinary.com/uploads/';
Optional. Default: / New URL to use instead of the URL Prefix Replacements.
If you'd like to play around with the class property settings, increment the buildDir
property after you adjust the settings and refresh the Wordpress Admin page. This will initiate the new build in the WPMarkdown Directory.
$markdown->buildDir = 'build_2';