At the Reading WordPress Meetup, on November 20th, 2018, I demonstrated how to code your own plugin for WordPress. This was a high level discussion, focused largely on the Q&A.

Here is the GitHub repository for the demo plugin I created.

What is a plugin?

  • Extra code, in addition to the theme, that is run after WordPress is loaded.
  • Plugins are stored in the /wp-content/plugins/ folder of your WordPress site.
  • Plugins must have a php file and a valid plugin header comment.
  • Only plugins activated from the plugin menu of the WordPress dashboard will run.

Why code your own?

  • Because you are a badass.
  • Because you need to tweak something specific to your site.
  • Because someone like Jason gave you custom code to patch your site.

Why not use functions.php in a theme or child theme? (Or edit a plugin or edit WordPress core.)

  • If you edit a theme or another plugin or WordPress core… that edit will be overwritten when the theme, plugin, or WP core is updated.
  • If you have your own child theme, you can put the code there. It’s less likely to be updated. However, your code stops running when you change your theme. Or maybe you don’t want a child theme.

Demos

  • Changing the excerpt length of archives.
  • Removing unused profile fields.
  • Setting a sitewide banner for Memberlite theme.

Other Demos?

  • WooCommerce
  • Ninja Forms
  • Paid Memberships Pro
  • Custom APIs