Tag Archives: widget

How To Create A WordPress Plugin Or Widget

This is a very simple Tutorial to create a Partner Links plugin.

A WordPress plugin is a snippet of code that extends on the functionality of WordPress, which can add to the inner workings such as an SEO extension for example, or it can add visual elements to the site, like a Facebook link. Widgets allow these code segments to be quickly and easily enabled or disabled within predefined areas such in newer themes, like a sidebar.

Prior to WP version 2, modifications and addons had to be hard coded into the source code or the theme. With today’s version and the ability to add plugins, we have a modular system of adding and removing functionality. This also makes upgrades a lot easier.

Here I show you how to create a very simple plugin, then enable it as a widget.

A simple WordPress plugin

Let’s create a new file in plugin inside your wordpress directory. Call it anything you like, I will use myplugin.php. Then we’ll add some code that creates partner links in your sidebar:

<?php
/*
Plugin Name: My Plugin
Plugin URI: http://www.itecsoftware.com/
Description: Partner Links WordPress Plugin
Author: Peter
Version: 1.0
Author URI: http://www.itecsoftware.com/
*/

function partnerLinks() {
echo “<h2>Partner Links</h2>”;
}
?>

Code inside /* */ are called comments, and in this case are used by WordPress to display information to the webmaster or whoever installs and configures it. The function partnerLinks will display the title, nothing more at this point. Save the file and you now should have a new plugin visible in the WordPress plugin section.

Read more »