So I have a plugin I have been working on. It adds a menu and multiple submenus.

Each submenu page contains a form, this form is created in a function called add_content_submenupagename. This function is used on the end of an add_submenu hook.

My question is, instead of having a tonne of similar form code in my main PHP file can I add in in seperate files then use these files as the content for each submenu page? I think this would be a cleaner solution then what I currently have.

Additionally I am using PHP to deal with the form once its submitted. As I now have multiple forms that need to be handled differently could this also be put into an includes file?

My aim is to make my plugin as easily maintainable as possible and having one huge file probably isn't the best approach.

Thanks in advance.


1 Answer 1


If I understand your question correctly, you are just looking for a way to include PHP files in other PHP files. There are a couple different ways, like include or require (as well as include_once and require_once, although it sounds like you'll be referencing the same file more than once possibly), both of which basically just bring an external php file in as if it were part of the file you are referencing it from. Here is a description on the differences between the two.

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.