I’d like to have a WordPress installation to serve blog content for my site under the directory /blog
My site runs on Spring Mvc and I’d like of course to maintain the basic layout (saying Header and Footer) of my site and integrate the wordpress blog on it.
What could be some approach to do this?
I’m using Tiles as my Template mechanism so I was basically thinking to handle /blog request with my requestDispatcher and internally forward the request to WordPress, then take the response and stream it inside the Content Tile section of my pages so to keep the basic look of my site for header and footer.
But I’m not sure of this approach.
How are you doing this? I can see they also have some RestAPI
If you simply want to use WordPress as a content management system and Spring MVC + Tiles to display your blog, then exposing your WordPress pages and posts with an API plugin such as WP Rest API or JSON API sounds like a great solution. This is how we manage our faq/contact/terms and conditions/etc. pages.
To make it faster, we synchronize (with a CRON job) each 30 minutes the content between our application database and the WordPress instance so that when the page is requested by an user the content is not pulled from WordPress but from the application DB. And then to make it even faster we created an Hibernate cache that lasts 30 minutes for this kind of data.
I have recently written a library in Spring, that uses WP REST API plugin to fetch content from WordPress. You might find it useful. Here is blog post on how to integrate Spring Boot and WordPress.