0

I use my functions.php file by including functions from other folders. I do this because of that when users want to edit functions directly I provide them find which function they want to edit.

In template path there are common functions.php file and a folder that storing functions. I call functions in functions.php from folder which named functions using require_once(TEMPLATEPATH.'/functions/function-name.php');

Storing functions isolated folders is suitable for WordPress template developing? Should I store whole functions in common functions.php or seperated?

It is my functions.php file enter image description here

1

2 Answers 2

1

Generally I keep the more back-end functions in functions.php and then use require() to call partials that contain groups of functions that are similar such as how the Underscores started theme written by the WordPress people does it.

But putting every single function in a separate file is a bit excessive.

1
  • I'm working on a function that calls whole php files from another folders using. I think it must be more light for performance.
    – Onur
    Aug 31, 2017 at 15:30
1

Your functions.php file looks a lot like mine. This is just organizational preference though, and you can arrange your files however makes most sense to you AND any team you might work with.

It's always a toss up between fewer, larger files or more, smaller files. This really matters more to someone traversing a single file vs a directory. Personally, I'd rather see filenames that give me clarity about what code to expect there instead of an entire site's code in a big functions.php with endless scroll.

This post gives good context and clarity around the spend if including files, and adds a bit of humour. If you are concerned about the include/require_(once) performances - it boils down to a few seconds per year - which people don't really notice.

1
  • Whole functions I created takes almost 900 lines and editing some codes in functions will be difficult for users. Users just open folder which store functions, they find function that want to edit by name of function.
    – Onur
    Aug 31, 2017 at 15:28

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.