Getting Started with WordPress Plugin Development
Beginner guide to creating your first WordPress plugin with automatic image injection for posts.
Writing plugins for WordPress may seem like a daunting task if you’re new to WordPress. But all it takes is a good starting point to get the ball rolling.
First, you will need to make the appropriate directories and files. In your /wp-content/plugins/ directory, make a new folder with your desired plugin name, and a .php file with the same name.
Open up the .php with your favorite editor and add some basic plugin info into the file header:
<?php
/**
* Plugin Name: Auto Image Plugin
* Description: Automatically adds an image to every post.
* Version: 1.0
* Author: SpinSpire
* Author URI: http://www.spinspire.com
*/
Add a filter function:
function auto_add_image( $content ) {
return $content . '<p><img src="YOUR IMG URL HERE"></p>';
}
add_filter('the_content','auto_add_image', 1);
This will call add_filter where the first value is the hook name “the_content” and the second being your function name “auto_add_image”. Save and enable the plugin under WordPress Plugins settings.
Make sure to read up on http://developer.wordpress.org/ and the WordPress Codex for more documentation.