ridgey28

WP RSS - Get Tags and Display Links

Jan 20th, 2016
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.92 KB | None | 0 0
  1. <?php //WordPress SimplePie - Add Tags with links to page - http://www.worldoweb.co.uk/2012/display-wordpress-posts-on-another-wp-blog
  2.  
  3. /******
  4. Include the following function before the loop, research the tag structure of your website first. Most WP sites have http://www.mywebsite/tag/
  5. ******/
  6. function wow_tags($item){
  7.     $url = 'https://www.mywebsite.co.uk/tag/';//CHANGE THE URL
  8.     $tags='';
  9.  
  10.       foreach ($item->get_categories() as $category)//loop through each tag
  11.         {
  12.             $tags.= '<a href="'.strtolower($url.$category->get_label()).'" title="'.$category->get_label().'">'.$category->get_label().'</a>';
  13.         }
  14.  
  15.     return $tags;
  16. }
  17.  
  18. /********
  19. Add the following inside the original/first foreach loop - remove old tag code first, if you followed my previous paste, as this is now inside the above function.  Style .mytags in css
  20. *********/?>
  21. <span class="mytags"><?php echo wow_tags($item);?></span>
Add Comment
Please, Sign In to add comment