Each week, when I do Weekend Hound Blogging, I insert the following at the end of the post:
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:
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)