I realize this is a subjective question, but I need some opinions on where to put functionality like meta boxes that belong to specific pages.

Let's say I have a template called Gallery Page. On that gallery page I have some custom meta boxes that I use for some gallery related, custom input from the user.

Up until now I have stored the meta boxes for different pages in different plugins, but I don't really like the idea of splitting the template and the meta box functionality apart. This is because my template won't work properly without the meta boxes, and the meta boxes are specific to that template.

I think of plugins like components that are page specific the same way my meta boxes are. I would be more comfortable leaving the meta boxes in a plugin if they were more generic.

I thought maybe to create a folder structure like this in the theme directory:

- templates
-- gallery-page
--- page-gallery.php
--- meta-boxes.php

This way I would at least have the functionality grouped together. Any thoughts?

1 Answer 1


I think that the most important question here is, Does this functionality add functionality to my theme or to my site?

Page templates in general are theme territory and in my opinion should stay in a theme. This does not mean any functionality on which a template depend should be in the theme as well.

These meta boxes that you are talking about can either be theme or site specific, and this is something that you should consider and answer yourself. If you need these to be available even if you switch themes, keep it in a plugin as it will give functionality to your site. If not, keep it in your theme.

Still, there is no wrong doing in keeping this in a plugin. This answer should also take into account things like readability, organisation of code and personal preference within a set of guidelines.

However, this all being said, I would keep common functionalities grouped together in either a plugin or a custom functions file which will be easy for me to remember later on where certain stuff are saved

  • In my case I guess they are theme specific. They are intended to be used on templates that are saved in the specific theme folder. I don't know how well I could just switch theme on this site. I have added a few custom post types and taxonomies that would get nowhere to go.
    – ptf
    Jan 12, 2015 at 9:49
  • It is always good to first sit down before you start on a project and write down what will be theme specific and what will be site specific. Site specific stuff is much easier in a MU plugin. Just on custom post types and taxonomies, they should always be in a plugin, althought templates for specific for them should remain in your theme due to markup and CSS Jan 12, 2015 at 9:57
  • So, plugins that add functionality like meta boxes to specific page templates can I pull into the theme, while custom post types and taxonomies should stay in their own plugins?
    – ptf
    Jan 12, 2015 at 10:38
  • Not necessarily. As I said, This does not mean any functionality on which a template depend should be in the theme as well. If these metaboxes is going to be very specific to the theme and you will not need it when you switch themes, move it into the theme. Otherwise, if you want to reuse these metaboxes when you switch themes, keep it in a plugin. It is always fast and easy to create a new template is a new theme which can be used with your metaboxes than doing everything again from scratch. And Yes, your custom post types and taxonomies should stay in plugin Jan 12, 2015 at 10:52
  • 1
    Currently I only have one theme that needs the meta boxes, so I'll move them in. If I later create an another theme which needs them, I will move them to separate plugins. A 3rd party theme wouldn't use those meta boxes anyway, so I think that's fine. Regarding the custom post types and taxonomies, they would be usable, if I remember correctly, in a 3rd party theme, so I'll leave them be (I guess that's the reason?).
    – ptf
    Jan 12, 2015 at 11:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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