Advertisement
ridgey28

WP RSS-Give Individual Cats their own CSS with Font Awesome

Apr 9th, 2016
133
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. <?php if ($maxitems == 0) echo '<div>No items.</div>'; else foreach ( $rss_items as $item ) : ?>
  10. <div class="midia">
  11.     <div class="icone">
  12.         <?php echo '<img src="' .get_first_image_url($item->get_content()). '"/>'; ?>
  13.            
  14.             <?php foreach ($item->get_categories() as $category)
  15.                 {
  16.                     if ($category->get_label() === 'Mobile'){
  17.                         echo  '<div class="tipo"><i class="fa fa-video-camera"></i>'.$category->get_label().'</div>';
  18.                     }
  19.                     else if ($category->get_label() === 'Coding'){
  20.                         echo  '<div class="tipo"><i class="fa fa-code"></i>'.$category->get_label().'</div>';
  21.                     }
  22.                     else if ($category->get_label() === 'Android'){
  23.                         echo  '<div class="tipo"><i class="fa fa-android"></i>'.$category->get_label().'</div>';
  24.                     }
  25.                     else {
  26.                         echo  '<div class="tipo"><i class="fa fa-heart"></i>'.$category->get_label().'</div>';
  27.                     }
  28.             }?>
  29.     </div>
  30.         <div class="mid-tit"><a href='<?php echo esc_url( $item->get_permalink() ); ?>' title='<?php echo esc_html( $item->get_title() ); ?>'> <?php echo esc_html( $item->get_title() ); ?></a></div>
  31. </div>
  32. <?php endforeach; ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement