An example site illustrating how to integrate WordPress managed content into a statically generated Middleman site.
Specifically, this example illustrates how to pull posts from WordPress and paginate them. It also illustrates how to include content from additional sources. In this case, we create an about page from a markdown file.
- Install WordPress
- Setup pretty permalinks in the WordPress settings and update the .htaccess file
- Download and install the WP REST API plugin
- Activate the WP REST API plugin
- Confirm that it is working by visiting
http://www.yoursite.com/wp-json/posts?type=post
If everything worked correctly, you will see an array of posts formatted as JSON.
This example illustrates how to fetch multiple pages of content and paginate it. For the best effect, you should enter more than 10 posts into your WordPress installation.
- cd into this project directory
- Run
bundle install
to install all dependencies
- Edit
config.rb
and update this stringhttp://middleman-wordpress-example.dev/wp-json
. It should point the your WordPress REST API. Do not include a trailing slash or any additional parameters. - Activate and configure deploy if you plan to deploy this via rsync, ftp, sftp, or git. See the documentation.
- To build and server the site on http://localhost:4567, run
middleman server
- To build the site into the build directory, run
middleman build
- To deploy the contents of the build directory, run
middleman deploy
(only if you activated and configured deploy)