0

I'm trying to build the theme that is easily customizable by other developers and chose to go get_template_part route so files can be easily overwritten in child theme.

My question is there some kind of limit for get_template_part until it hurts performance?

For example, I'm using it for building a card UI, so each card has 5-10 get_template_part calls. If page displays 40 cards, that would be 400 disk lookups — could it hurt the performance? Is it better to move to regular functions (e.g. template tags)?

  • 1
    My personal opinion: don't worry about that (too much). Create the theme in a way that all pages can easily be page cached, e.g. via getting dynamic content via the REST API instead of putting them on the page itself – kero Dec 11 '18 at 13:06
  • Why do you need 5-10 template parts for a single card? Why can't the child theme just replace the whole card? Is there that much in it? – Jacob Peattie Dec 12 '18 at 6:28
  • @JacobPeattie yeah, the card itself is pretty sophisticated, as it can contain multiple elements as review stars, icons, video and so on. For the ease of editing those were separated and moved outside the card template – Runnick Dec 12 '18 at 13:25

Your Answer

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

Browse other questions tagged or ask your own question.