rajeshhonrao
Forum Replies Created
Viewing 1 replies (of 1 total)
-
Forum: Fixing WordPress
In reply to: Permalink : %tag% not workingWhich version are you using? I am using WordPress 2.9.2,had same issue, here is the patch for ‘wp-includes/link-template.php’
*** link-template.php 2009-12-14 05:09:55.000000000 -0500 --- link-template_patched.php 2010-06-21 14:29:24.000000000 -0400 *************** *** 88,93 **** --- 88,94 ---- $leavename? '' : '%postname%', '%post_id%', '%category%', + '%tag%', '%author%', $leavename? '' : '%pagename%', ); *************** *** 128,134 **** --- 129,151 ---- $category = is_wp_error( $default_category ) ? '' : $default_category->slug; } } + + if ( strpos($permalink, '%tag%') !== false ) { + $tags = get_the_tags($post->ID); + + if ( $tags ) { + usort($tags, '_usort_terms_by_ID'); // order by ID + $tag = $tags[0]->slug; + } + // show default tag in permalinks, without + // having to assign it explicitly + if ( empty($tag) ) { + $default_tag = get_tag( get_option( 'default_category' ) ); + $tag = is_wp_error( $default_tag ) ? '' : $default_tag->slug; + } + } + $author = ''; if ( strpos($permalink, '%author%') !== false ) { $authordata = get_userdata($post->post_author); *************** *** 147,152 **** --- 164,170 ---- $post->post_name, $post->ID, $category, + $tag, $author, $post->post_name, );
Viewing 1 replies (of 1 total)