I'm working on an e-commerce site and a lot of customization needs arise. There are many codes in the child theme. Hundreds of lines... I always have this question in my mind: Is it better to write a new plugin or write code to function.php ? I have read some studies and articles on the internet about this.

General opinion: The Wordpress plugin is a logical decision.

It is said that writing a plugin is better because it can be classified according to the work it does, as well as the possibilities such as updating and deactivating. However, I couldn't find a definitive explanation, basically on a performance basis. If anyone has knowledge on this subject and can explain it technically, I would appreciate it.


1 Answer 1


There's zero meaningful difference in performance between plugins and functions.php. All plugins are is PHP files that WordPress will run as it loads, and functions.php is just a file in the theme that WordPress run as as it loads.

Performance is not a consideration when choosing between a plugin and functions. The right choice depends entirely on what the code does, and even then is largely a matter of opinion, so you're not going to get a definitive answer.

The closest you might get is the rules for submitting themes to wordpress.org. Those rules state that themes should not include:

  • Custom post types
  • Custom blocks
  • Custom roles
  • Custom user contact methods
  • Custom mime types
  • Shortcodes
  • Functionality that is not related to design and presentation

These rules are not at all related to performance. They enforce a certain point of view of what best practices are, but they primarily exist to ensure users can easily switch themes without loss of functionality or content.

Please note that these are merely the rules for a single theme repository, albeit the most popular one. They may or may not be appropriate for other repositories or projects. That again depends entirely on the nature of the code and the project, and would be a matter of opinion.