Adventures in WordPress Vol. 3 - Converting WordPress to Bedrock

Bedrock is a modern WordPress stack that gets you started with the best development tools, practices, and project structure.

This post will be a little light on descriptions as it's fairly straightforward to move an existing WordPress project into a Bedrock stack. It's mostly moving directories around.

Backup the existing database

Always a good idea before messing with the database and performing a lot of updates.

$ mysqldump [database] -u [user] -p | bzip2 -c > [database]-$(date +%Y-%m-%d-%H.%M.%S).sql.bz2

Update the database

Replace all instances of wp-content with app

> UPDATE `wp_posts` set `guid` = replace(`guid`,'wp-content/uploads/','app/uploads/');

And again for post_content:

> UPDATE `wp_posts` set `post_content` = replace(`post_content`,'wp-content/uploads/','app/uploads/');

Moving plugins to composer.json

    "wpackagist-plugin/wp-instagram-widget": "^1.9",
    "wpackagist-plugin/akismet": "^3.1",
    "wpackagist-plugin/amazon-link-engine": "^1.2",
    "wpackagist-plugin/google-analytics-for-wordpress": "^5.5",
    "wpackagist-plugin/jetpack": "^4.0",
    "wpackagist-plugin/w3-total-cache": "0.9.4.1",
    "wpackagist-plugin/wordpress-seo": "^3.3",

    ...

Themes

$ cp -r ./wp-content/themes/[theme name] [bedrock]/web/wp/wp-content/themes

And just like that we're now running a Bedrock based wordpress installation.