I use custom permalink structure:
/%tag%/%postname%/
and it is not working. I get url – http://mydomain.com/%tag%/post/. So there is no tag name, just %tag%. If i place %category% instead ot %tag%, everithing is ok.
Can somebody solve this problem?
2 Answers
@Atari asked for a solution.. People who do not have one should not butt in!
I have the same issue. All other %category% %postname% %post_id% etc. resolve fine, but %tag% remains %tag% in the final permalink!
I think it is a bug. I came across a patch which was for an older version. I did not try it yet ( I do not know how to use it either 😛 ) because I am using the latest version (3.0.4 I think).. but the problem is still there!
I do not want to start the url with %tag% but I need it down the URL. The point is that it should work.. regardless of how I use it!
@Atari if you find a solution please do share it 🙂
here is the patch I found.. I would appreciate anyone telling me how to use it too 🙂
*** 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,
);