Advertisement
ridgey28

WP RSS - Give Individual Categories their own CSS

Apr 6th, 2016
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2.  
  3. /****
  4. WordPress SimplePie. Display Categories from RSS Feed and give individual ones their own CSS classes - http://www.worldoweb.co.uk/2012/display-wordpress-posts-on-another-wp-blog
  5. Please note that Tags may also be displayed as categories within the RSS feed
  6. ****/
  7.  
  8.  
  9. /*Add inside the main foreach loop*/
  10.  
  11.  foreach ($item->get_categories() as $category)
  12.     {
  13.         if ($category->get_label() === 'Mobile'){
  14.                 echo  '<span class="mobile">'.$category->get_label().'</span>';
  15.         }
  16.         else if ($category->get_label() === 'Coding'){
  17.                 echo  '<span class="coding">'.$category->get_label().'</span>';
  18.         }
  19.         else if ($category->get_label() === 'Android'){
  20.                 echo  '<span class="android">'.$category->get_label().'</span>';
  21.         }
  22.         else {
  23.                 echo  '<span>'.$category->get_label().'</span>';// gets the remainder of the categories - can also be omitted
  24.         }
  25.     }?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement