Jump to content
Sign in to follow this  
AaronS

Icons to Post Titles

Recommended Posts

AaronS

Sorry if there's a simple answer to this question, but I'm really new to all of this. I wondered if anybody knew a simple way to add icons next to or near post titles. I'm thinking sort of a Tumblr-style effect, but with custom icons for different categories. I'm working on a site for a student group, which has different committees and I'd love to set it up where they different committees can post updates and visitors could easily see the different post types based on an icon. Thanks in advance for the help.

Share this post


Link to post
Share on other sites
kastelic
Ok here is a solution for you. First, you must have Platform Base activated. Then paste this in platformbase/functions.php: [code] add_action('pagelines_loop_post_header_start','custom_icons'); add_action('pagelines_loop_clip_start','custom_icons'); function custom_icons(){ if ( in_category('something') ) { echo "something icon goes here"; } else if ( in_category('uncategorized') ){ echo "uncategorized icon goes here"; } } [/code] The two add_action lines enable the code in a full width excerpt and also before the title in the clips (magazine mode) since they use different hooks. YOu have to change the "something" and "uncategorized" to the name of your own categories. Change the "somtehing icon goes here" to either an html image tag, or a div with a class that you will set a background to in CSS. Keep repeating this line as many times as you need for each category: [code] else if ( in_category('uncategorized') ){ echo "uncategorized icon goes here"; } [/code] For example, one with 3 categories: [code] add_action('pagelines_loop_post_header_start','custom_icons'); add_action('pagelines_loop_clip_start','custom_icons'); function custom_icons(){ if ( in_category('something') ) { echo "something icon goes here"; } else if ( in_category('uncategorized') ){ echo "uncategorized icon goes here"; } else if ( in_category('third') ){ echo "third icon goes here"; } } [/code]

Share this post


Link to post
Share on other sites
AaronS
kastelic, this is fantastic. I actually haven't gotten it to display the images from the html image tag, which I think is because I'm using WAMP server and it won't display dynamic content. I can get it to display placeholder text, though. I think as soon as I put it online that issue will be resolved. Thanks so much.

Share this post


Link to post
Share on other sites
AaronS
So I was able to get the post icons to work. Next question: is it possible to put more than one icon (maybe up to three?) per post? Currently, only one of the icons will display, even if I have multiple categories selected. Thanks in advance...

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this  

×