Icons by your post title
It was suggested to me to have icons next to my title that represented what the post was about, ex. a post for illustrator would have the illustrator logo next to the title. And so I have done so.
Now in this tutorial I will show you have to make it so your post automatically puts the icon next to each title and with the correct icon for that category. This is a really simple technique.
Goto your mainIndex Template page and find the line
<a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"> <?php the_title(); ?>
Right above it put this code.
<?php if ( in_category('27') || in_category('47')): ?>
<img src="URL of image" alt="description" />
<?php elseif( in_category('46')): ?>
<img src="URL of image" alt="description" />
<?php endif; ?>
What this does is if the post is in category 27 or 47 it will put the image of the icon next to the title, if it is not, then it will check, if it is in category 46 and put that icon etc. You can add as many elseif statements, and you can add as many or’s inside of the if statement, so you can have something like
<?php if ( in_category('1') || in_category('2') || in_category('3') || in_category('4') || in_category('5') || in_category('6')): ?>
If you wish to do the same for ’singlepost’ pages just add the same code into the singlepost template page.
Very simple code and effective. Good luck, any questions please ask ![]()
December 10th, 2007 at 5:16 pm
Well demonstrated examples. Thank you!
December 11th, 2007 at 10:22 am
Very Good
February 8th, 2008 at 7:16 pm
genious. thanks for this.
July 11th, 2008 at 11:12 pm
How do I designate which category my posts belongs to? Otherwise, it won’t know which picture to display… I’m using blogger. thanks