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 remove the current tag from 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];
- $list = ''; $sep = '';
- //get the post tags
- $posttags = get_the_tags($post->ID);
- if($posttags) :
- //build new tag list
- foreach( $posttags as $tag ) {
- if( $tag->slug != $this_tag ) {
- $list .= $sep . '<a href="' . get_tag_link( $tag->term_id) . '">' . $tag->name . '</a>';
- $sep = $separator;
- }
- if( !$list ) $list = ' - ';
- }
- $list = $before . $list . $after;
- endif;
- endif; //end of is_tag()
- return $list;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement