Question

I've been wondering what would be the best option:

  • Creating a wordpress theme
  • Using wordpress only as backend and using a MVC framework for the rest

I've never worked with wordpress themes before, but I've been taking a look at the basic theme to try to understand how it works and how it can be customized, and... Wow! Wordpress insiders look really ugly!

HTML mixed with PHP everywhere, functions printing HTML markup, global variables which seem to appear from nowhere...

I also noticed that just to change the appearance of a category section I would need to modify multiple files being called by different PHP functions or even the calls to the functions, such as wp_link_pages, the_content, edit_post_link...

After all this mess, I'm wondering what is the real advantage of using a wordpress theme rather than calling some wordpress functions (ideally which don't print info but just return data) inside a MVC framework, where things will be much more organized.

Was it helpful?

Solution

There is a big advantage on separating the backend from the frontend. Besides the code quality, performance and maintenance time are improved.

I have created a theme using Ember.js and WP REST API ( with custom routes ) and the results are amazing.

So yes, if you have the knowledge of MVC and a deep knowledge of WordPress Core, go for it.

OTHER TIPS

There would be no real advantages of theme vs backend since you would simply be rolling WP functions into your own framework and having to then maintain them. Doing so for the sake of a clean template is not a good idea.

The only strong use case for doing this I can think of would be when you have to bootstrap a WP backend into an existing site and you need minimal functionality.

For example:

$content = new LoadWpContent();// class which loads WP and does simple content query
echo $content->getPostContent( 'Some Post' ); 

The better option to roll your own is to just use the WP API : https://github.com/WP-API/WP-API

Licensed under: CC-BY-SA with attribution
Not affiliated with wordpress.stackexchange
scroll top