I’m trying to create certain modulair blocks which I can add to multiple pages in WordPress. But I use sidebar-[name].php files for this, what is the best practice for this? Should you add them to a function or add them in a sidebar…
It feels Kinda off using many sidebar’s. It would be nice if I could add them to a sub-folder in the template. Checkout the image. How do you do this?
I would say to add them as template parts as in content-[name].php. For instance in
page.php
you could have something like:It seems to make more sense as it is content after all.
Who says you can not put template files into sub-directories?
Your custom-templates can be put wherever you want them to be – because it is you who includes them, anyway.
If you see the Codex on
get_template_part
, you find the following: