Skip to content

Geeking Out for Greyhounds (or, My First and Probably Only WordPress Plugin)

Each week, when I do Weekend Hound Blogging, I insert the following at the end of the post:

[saveagrey]

This requires me to find an old post, copy and then paste the text into the new post. Surely, thought I, there must be an easier way, which got me thinking about trying to create a plugin to do that for me.

I studied some of the simpler in-post plugins I already use and tried to decipher the PHP.

I read “Writing a Plugin”, studied the “Plugin API” page and “Plugin API/Hooks”on the WordPress site, as well as “How to Write a Simple WordPress Plugin” on Asymptomatic. Then, I started putting together a PHP file, tinkering and playing until I eventually had a plugin that allows me to type:

[ saveagrey ]

(without the spaces) and have this appear:

[saveagrey]

The cool thing is that it can be easily changed so that the text and links go anywhere or say anything, which might make this useful for anyone who occasionally wants some message at the end of certain posts such as vote for so-and-so at the end of all political posts or something to that effect.

This little exercise was a lot of fun. I really enjoyed trying to decipher the PHP since I know nothing about that language. Ultimately it became something of a puzzle that could only be solved through logic. When I figured out the solutions to the problems I encountered, I was rewarded with something that will save me time and possibly be of use to anyone who uses WordPress and wants to help save retired racing greyhounds.

So, there it is. My first plugin: Save a Greyhound (click to go to the download page)

Published inWriting

2 Comments

  1. Cool – just downloaded and checked it out – I too am learning to write a plugin – seems like a very daunting task for me, and with only self-taught coding I have been a bit overwhelmed. Asymptomatic heled *a bit* – will try to write a couple very basic ones too.

    Nice work!

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.