Convert WordPress Into Markdown Files With YAML Front Matter (PHP Script)

How can we safely get the content from our Wordpress site into a YAML format ready for static site distribution? Here’s a PHP script which can easily get the content from your Wordpress database. You will need to be able to access the server your Wordpress is installed on to run the code and download the output files.