Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- add_filter('the_tags','the_tags_in_tag_archive');
- /*filter to replicate 'the_tags()' in a tag archive, to un-link the current tag in the list
- * alchymyth 2011
- */
- function the_tags_in_tag_archive($list) {
- if( is_tag() ) : //do the following only in tag archives
- global $post;
- $this_tag = get_query_var('tag');
- //retrieve the $before,$sep,$after variables from the list
- $before = explode('<a href', $list);
- $before = $before[0];
- $afters = explode('</a>', $list);
- $after = array_pop($afters);
- $separator = explode('<a href', $afters[1]);
- $separator = $separator[0];
- $sep = '';
- //get the post tags
- $posttags = get_the_tags($post->ID);
- if($posttags) :
- //build new tag list
- $list = $before;
- foreach( $posttags as $tag ) {
- $list .= $sep;
- if( $tag->slug != $this_tag ) $list .= '<a href="' . get_tag_link( $tag->term_id) . '">';
- $list .= $tag->name;
- if( $tag->slug != $this_tag ) $list .= '</a>';
- $sep = $separator;
- }
- $list .= $after;
- endif;
- endif; //end of is_tag()
- return $list;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement