最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

php - Wordpress Template Engine?

programmeradmin1浏览0评论

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.

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.

Share Improve this question asked Aug 19, 2018 at 12:42 manifestormanifestor 3136 silver badges15 bronze badges
Add a comment  | 

3 Answers 3

Reset to default 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.

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.

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.

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论