Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*A simple way to supplement WordPress feeds. In this case, adding comment count and categories.
- Just add this to your theme's function.php and you're off to the races.
- */
- function ulfben_supplement_feeds($content){
- $post_categories = wp_get_post_categories(get_the_ID());
- $cat_list = array();
- foreach($post_categories as $cat_id){
- $cat_list[] = '<a href="'.get_category_link($cat_id).'" target="_top">'.get_cat_name($cat_id).'</a>';
- }
- $comments = get_comments_number();
- if($comments){
- $comments .= ($comments == 1) ? ' comment' : ' comments';
- }else{
- $comments = 'A penny for your thoughts!';
- }
- $comments = '<a href="'.get_comments_link().'" target="_top">'.$comments.'</a>';
- return $content.
- '<div style="display:block">
- <small>Posted in: <em>'.implode(', ',$cat_list).'</em><br />'.
- $comments.
- '</small>
- </div>';
- }
- add_filter('the_excerpt_rss', 'ulfben_supplement_feeds');
- add_filter('the_content_feed', 'ulfben_supplement_feeds');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement