Back to blog
Plugin DevelopmentMarch 25, 20265 min read

Custom WordPress Plugin vs functions.php: Which Should You Use?

Knowing where to put custom code in WordPress saves you from theme-switch disasters and update nightmares.

Stack Overflow says 'add this to functions.php'. WPBeginner says 'use a code snippets plugin'. Your last developer dropped a 2,000-line functions.php. So which is right? Depends on the code.

Use functions.php for theme-specific code

Custom post-meta on theme templates, theme-specific hooks, enqueueing the theme's own assets — yes. This code is dead weight if you switch themes anyway.

Use a site-specific plugin for everything else

Custom post types, taxonomies, integrations with third-party APIs, business logic — these survive a theme switch and shouldn't disappear with it. Make a tiny plugin: one PHP file with the right header is enough.

<?php
/*
Plugin Name: Acme Site Customizations
*/
// Your code here.

Use mu-plugins for must-run code

Code in /wp-content/mu-plugins/ runs on every request and can't be deactivated. Great for security policies, environment-specific config, or anything that must never be turned off.

Avoid code snippet plugins for production

Fine for prototyping. Bad for production: code lives in the database (not version controllable), and if the plugin breaks, all your snippets die with it.

wordpress functions.phpcustom wordpress pluginmu-plugins wordpresscode snippets wordpresswhere to add wordpress code

Need help with this on your site?

Our senior developers fix this exact issue daily. 25% upfront, 75% after it's done.