Sunday, 2 February 2014

Where to put my code: plugin or functions.php?

Is there an easy to understand scheme to decide what kind of code belongs to a plugin or the theme’s functions.php?
There are many cases and many debates about that topic, mostly because there are some misconceptions about the inner workings of WordPress. I am asking for an answer based on facts, not on opinions.
It should explain how to handle these points (and probably more):
  • custom post types and taxonomies
  • contact forms
  • shortcodes
  • custom widgets
  • add_theme_support( 'automatic-feed-links' );
  • SEO functions like custom meta elements
  • theme switch
There are often pros and cons for both sides. Our most popular question Best Collection of Code for your functions.php file got a lot of code snippets as answers that are at least debatable.
We need criteria a beginner can understand, maybe a check list – with reasons.
See also the related question by Chip Bennett on our meta site: Questions specifically asking for a solution "without a plugin"

0 comments:

Post a Comment

Twitter Delicious Facebook Digg Stumbleupon Favorites More