I like to include a copyright notice on my posts, a small one down on the lower right, and a couple of links for RSS and Twitter. The problem is that I always go back and add it as an afterthough. So I write a post, proof it, convince myself that it’s perfect, post it, and then I notice that I didn’t put that little footer at the end.
I use wordpress.com to host my site. I looked around the admin console for something pertaining to post templates but didn’t find anything. I googled a little to see whether such a feature exists, but I didn’t find anything.
Then it occurred to me. Matt Malone, you handsome devil, aren’t you a professional software developer? And don’t you have the gall to write a blog proclaiming yourself such? Why don’t you write something yourself? So I did. I wrote a very simple greasemonkey script. Here it is below. Feel free to install the script if you use wordpress.com and think it would be useful.
// ==UserScript== // @name WordPress Post Template // @namespace oldfashionedsoftware.com // @description Inserts some template text in new blog posts // @include http://matthewmalone.wordpress.com/wp-admin/post-new.php // ==/UserScript== var postTextAreaList, postTextArea; postTextAreaList = document.evaluate( "//textarea[@name='content']", document, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null); postTextArea = postTextAreaList.snapshotItem(0); postTextArea.value = "Your template text here";
Don’t forget to
subscribe to my RSS feed, or
follow this blog on Twitter.
Copyright © 2008 Matthew Jason Malone
September 15, 2008 at 1:12 pm
Thanks for the script…I’ve been looking for a solution to this problem also. I don’t have any experience writing my own greasemonkey scripts. I modified the one above for my blog. How do I execute it on the post page? (forgive my ignorance)
September 20, 2008 at 11:37 pm
You need to change the “@include” line to be the new post URL for your blog. Then you just need to install greasemonkey, right click the greasemonkey icon, select “New User Script..”, fill in the fields, and then paste in the script and save when the editor comes up. After that, the script should work.
June 27, 2009 at 10:19 am
Hi, I’m trying to use your script and as someone who doesn’t have alot of experience with the coding I’m not sure what I’m doing. I’m assuming that I need to change the text in Blue but what do I change this to? postTextAreaList = document.evaluate( “//textarea[@name='content']”
I think I have everything else sorted out. Your help would be greatly appreciated.
June 27, 2009 at 12:39 pm
Hi, Just to let you know that I got it working, thank you. Could I ask you though if it’s possible to have a list and not just one line and is it possible to add a.png file at the end?