Share Pastebin
Guest
Public paste!

azizhp

By: a guest | Aug 21st, 2009 | Syntax: PHP | Size: 1.34 KB | Hits: 1,319 | Expires: Never
Copy text to clipboard
  1. <?php
  2. /*
  3. Plugin Name: AHP Tags to Hashtags
  4. Plugin URI: http://metablog.us
  5. Description: when active, automatically appends all tags to the post as hashtags to the post title in the output RSS feed.
  6. Version: 1.0
  7. Author: Aziz H. Poonawalla
  8. Author URI: http://metablog.us
  9.  
  10. Copyright 2009  AZIZ POONAWALLA  (email : APOONAWA dash BLOG at YAHOO dot COM)
  11.  
  12.     This program is free software; you can redistribute it and/or modify
  13.     it under the terms of the GNU General Public License as published by
  14.     the Free Software Foundation; either version 2 of the License, or
  15.     (at your option) any later version.
  16.  
  17.     This program is distributed in the hope that it will be useful,
  18.     but WITHOUT ANY WARRANTY; without even the implied warranty of
  19.     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  20.     GNU General Public License for more details.
  21. */
  22.  
  23. function ahp_tags2hashtags($title) {
  24.  
  25. $taglist = "";
  26. $posttags = get_the_tags();
  27.  
  28. if ($posttags) {
  29.  
  30.         # for each tag,
  31.         foreach($posttags as $tag) {
  32.  
  33.                 # get tag name
  34.                 $tagname = $tag->name;
  35.  
  36.                 # remove spaces from tag
  37.                 $tagname = str_replace(" ","",$tagname);               
  38.  
  39.                 # prepend # symbol and append to hashtag list
  40.                 $taglist = $taglist . " #" . $tagname;
  41.         }
  42. }
  43.  
  44. $title = $title . $taglist;
  45.  
  46. return $title;
  47.  
  48. }
  49.  
  50. add_filter('the_title_rss', 'ahp_tags2hashtags');
  51.  
  52. ?>