WordPress Plugin or the Theme's functions.php?
Why the Distinction Matters
A theme is meant to control presentation — layout, styling, visual structure — while a plugin is meant to add functionality independent of how the site looks. Mixing genuine functionality into functions.php ties that functionality's survival to the theme staying active, which becomes a real problem the moment anyone changes themes, whether deliberately (a redesign) or accidentally (switching to troubleshoot an unrelated issue).
What Belongs Where
- Custom post types, taxonomies, shortcodes, and integrations should always live in a plugin — these represent site functionality and data structure that has nothing to do with which theme happens to be active.
- Purely visual tweaks specific to the current theme's markup (adjusting how the theme itself renders something) are reasonable in a child theme's functions.php, since they're inherently tied to that theme's structure anyway.
- A "must-use" plugin (placed in
wp-content/mu-plugins) is worth considering for genuinely critical functionality that should never be accidentally deactivated, since MU plugins can't be turned off through the normal plugin interface. - A common mistake is building up a large, unmanageable functions.php over time simply because it was the easiest place to add "just one more thing," which eventually creates exactly the fragility a proper plugin structure avoids.
Getting This Right
- Ask whether the feature should survive a theme change — if yes, it belongs in a plugin.
- Create a small, dedicated site-functionality plugin rather than relying on functions.php for anything beyond genuinely presentational tweaks.
- Migrate existing functionality out of functions.php into a proper plugin if it's grown to include things that shouldn't be theme-dependent.
Need existing functions.php code properly reorganized into a maintainable plugin? See WordPress bug fix.