One question I get asked a lot is how I added the padlock icons next to each of the private entries.
The good news is that it’s not difficult at all. In my case, I use a slightly different modification of this code, however, the below will work for most general purposes.
Before modifying any files, please make sure you have a back up copy.
- Upload the padlock image to wherever you want it on your server and make a note of its URL.
- Locate all the theme template files that are likely to have a post title in it (i.e. index.php, single.php, archive.php, category.php, and so forth), because in each of these templates you will be adding a bit of code.
- Find the reference to the title in each of these template — <a href=”…”><?php the_title(); ?></a> — and add the following code after it:
<?php if(is_private()) echo '<img src="…" alt="padlock" title="Private" />'; ?>(Remember to link to the location of the padlock image in the source.) - Save and upload your modified files, refresh your site, and you should see padlocks for any private entries.




I tried this on my blog, but it gives me an error.
# May 21st, 2008
Jenny, I’m sorry you get an error, but without more information, there’s no way for me to tell you why you’re getting the error. It may just be that you copied/pasted it directly from the content of this entry and a stray character made its way into the code.
~ Teli
# May 26th, 2008
I got the same error as Teli. You need to have the post levels plug in installed for this code to work.
Hope that helps.
-Jason
# July 8th, 2008
Hi there, I was wondering if you know how to add the padlock icon to the Clean Archives Reloaded plugin (link below). I found where it’s suppose to go but I don’t know how to insert it because I hardly know any PHP! If you could help, that would be great!
Thanks! =)
http://www.viper007bond.com/wordpress-plugins/clean-archives-reloaded/
Also, what version of WP are you running? I’m using 2.5 but I find that the Post Levels plugin doesn’t work if you upgrade. Do you have a fix?
# April 20th, 2009