Customising WordPress Without Modifying Core, Theme Or Plugin Files
A standard WordPress install is incredibly powerful and flexible. For a lot of people, WordPress out of the box plus one of the stock WordPress themes is enough. But the possibilities for customization are endless; you can add plugins and other themes. Sometimes these do just what you want. Sometimes you need to ... tweak WordPress.
A very high proportion of the customization advice you'll find on the web starts with these lines ... add the following to the end of your theme's
functions.php or even worse, advises that you modify the source code of your theme or your plugins. This is bad for many reasons:
- Editing your theme's
functions.phpmakes theme specific customizations; change your theme and your customizations will no longer get loaded.
- When your theme and plugins get updated you'll find all your careful hand crafted customizations get overwritten and lost.
- A lot of theme and plugin authors won't offer support for changes you might have made to the source code.
- Your customizations might work; but you might also inadvertently make some other changes which will stop things working.
WordPress doesn't yet support a way for site specific customizations to be made and loaded without touching theme, plugin or core files; that's why I wrote WP Customizer and that's what this plugin is for. When WordPress does support such a way, this plugin will thankfully be obsolete.
There's another, not entirely altruistic, reason behind this plugin. One of the most common support requests I get for WP Biographia is to help with clashes between someone's theme's CSS and the plugin's CSS. Once that's been resolved, the next question is almost always how do I load this custom CSS? The answer is now straightforward. Put your CSS file in a directory in the root of your WordPress installation, install WP Customizer, tell it to load custom CSS files and where to find them and you're done. No editing of
functions.php. No learning now to hook into the
wp_enqueue_scripts action, no learning how to call
wp_enqueue_style. It should all just work.
WP Customizer uses the file system as a data-store metaphor and allows you to main a library of common customisations that are independent of the theme and plugins you're currently using. Out of the box, the plugin looks for custom files to load in the root of your WordPress installation in a set of named directories which should be relatively self explanatory,
common_functions and so on for CSS and for scripts.
But you can just as easily create your own directory structure, put together in a way that makes sense to you, perhaps something along the lines of ...
site/admin/scripts and so on
... you're limited only by the limitations of your file system and the way of organising things that make sense to you.
Just remember, when you read something that says just add the following code to your theme's
functions.php, ignore this little piece of advice and add it a local customisation file and load that through WP Customizer instead. Your WordPress site will thank you for it someday.
To download or install WP Customizer, either search for WP Customizer from the WordPress Dashboard or go to plugin’s page on the official WordPress plugin repository. If you want to fork the source code of the plugin, you can find it on the plugin’s GitHub page at https://github.com/vicchi/wp-customizer.