3

I'm in a need to convert an existent design into wordpress and before starting I was curious to know: Is it correct to use pure "naked" PHP when adding logic to templates in wordpress? Wordpress uses no template engine like Twig or Blade by default? I'm pretty suprised, so before starting to work on that project and doing everything in pure PHP (with the opening <?php and closing hassle ?>) I wanted to ask here. This way of doing things seems very outdated to me.

7

Correct, there is no PHP templating engine built into WordPress. This does however give you the flexibility to use a templating engine such as Twig or Blade (and I have worked on sites using each of those), or even completely headless using the REST API.

2
  • Thanks, and that works out of the box by installing a plugin (I guess), for blade for example? – manifestor Aug 19 '18 at 12:55
  • 1
    Yes it appears there are plugins for that. You could also manually include the libraries I'd expect – cameronjonesweb Aug 19 '18 at 14:43
0

As many will point out - PHP itself could be considered a "template language" - and from a performance point of view, the less additional layers of abstraction you add - the quicker and more performant the site will probably load.

That said - frameworks are popular for a reason - and that is generally to do with simplification and standardization - so, I offer the suggestion of a WordPress Template Engine called Willow - which might be of interest to you.

As a logic-less TE, is has the added benefit of forcing a clean separation of concerns and keeping conditional checks out of the templates - for some people this is not important or seen as a hinderance, but once you adjust to working this way it feels much cleaner.

  • Disclaimer - we wrote this software and use it on our projects.
-1

Yes. I agree, WordPress PHP is rather outdated at times.

As Invariant Change says, page builders offer a great solution. Divi is amazing. If you want something a little trimmed back, there is also the Genesis Framework.

However, because this is so trimmed back, you end up adding lots of plugins to get it to do what you want it to do, which then means lots of maintenance, debugging and slower site with all the server calls, which is why Divi is so good. It's all contained in a fast streamlined self-contained package that is designed from the top up to work in unison, rather like Apple products.

Genesis is best suited to theme developers who intend to resell their themes in markets such as Envato.

3
  • 1
    Thanks. Yes, I used Genesis Framework and stopped using it for the very reason you state. It's great for the people that are reselling, but for me, who wants something that lets me make a good site quickly, Divi is far superior. Time is money, Divi means more profit :) – Invariant Change Aug 19 '18 at 13:31
  • 1
    I just checked. Divi has a built-in template engine. So probably the best solution? – Cryptomanic Aug 19 '18 at 13:35
  • 1
    Oh yes. I should have mentioned that. The template system Divi uses lets you assign who pages as template, or individual elements. You can also make them global templates, which means, if you update it, it updates every instance of it site wide. They are adding for features to it the template engine soon also, so it will become even more powerful. – Invariant Change Aug 19 '18 at 13:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.