[wp-trac] [WordPress Trac] #8861: get_tag_link only works for post_tag

WordPress Trac wp-trac at lists.automattic.com
Wed Jan 14 23:31:41 GMT 2009


#8861: get_tag_link only works for post_tag
-------------------------+--------------------------------------------------
 Reporter:  olivM        |       Owner:  ryan         
     Type:  enhancement  |      Status:  new          
 Priority:  normal       |   Milestone:  2.8          
Component:  Taxonomy     |     Version:  2.7          
 Severity:  normal       |    Keywords:  taxonomy link
-------------------------+--------------------------------------------------
 the get_tag_link function only works for the post_tag taxonomy.

 so perhaps we should have get_tag_link( $tag_id, $taxonomy ) or
 get_term_link( $term_id, $taxonomy )

 which should look like this :


 {{{
 function get_tag_link( $tag_id, $taxonomy = 'post_tag' ) {
         global $wp_rewrite;
         $taglink = $wp_rewrite->get_extra_permastruct($taxonomy);

         $tag = &get_term( $tag_id, $taxonomy );
         if ( is_wp_error( $tag ) )
                 return $tag;
         $slug = $tag->slug;

         if ( empty( $taglink ) ) {
                 $file = get_option( 'home' ) . '/';
                 $taglink = $file . '?'.$taxonomy.'=' . $slug;
         } else {
                 $taglink = str_replace( '%'.$taxonomy.'%', $slug, $taglink
 );
                 $taglink = get_option( 'home' ) . user_trailingslashit(
 $taglink, 'category' );
         }
         return apply_filters( 'tag_link', $taglink, $tag_id );
 }
 }}}

-- 
Ticket URL: <http://trac.wordpress.org/ticket/8861>
WordPress Trac <http://trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list