Home » Wordpress » Integrating WordPress with Spring MVC

Integrating WordPress with Spring MVC

Posted by: admin December 2, 2017 Leave a comment

Questions:

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

Answers:

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.

Questions:
Answers:

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.

Leave a Reply

Your email address will not be published. Required fields are marked *