Ultimate Tag Warrior fix for WordPress 2.2.1
Jul 24, 2007 I Coding.I've just installed WP 2.2.1 and had some problems with pretty URLs...
So I've played a bit (note that it's my first contact with WP so I'm not sure if my method is good) with the code...
Well... stop talking... here's my solution:
First of all: fix .htaccess...
My .htaccess file contents:
-
# BEGIN WordPress
-
-
RewriteEngine On
-
RewriteBase /# Basic tag requests: "tag/TAGNAME" => "index.php?tag=TAGNAME"
-
RewriteRule ^tag/?(.*)$ /index.php?tag=$1 [L]
-
RewriteRule ^tag/?(.*)/$ /index.php?tag=$1 [L]
-
-
# Multipage requests: "tag/TAGNAME/page/N" => "index.php?tag=TAGNAME&paged=N"
-
RewriteRule ^tag/?(.*)/page/?(.*)$ /index.php?tag=$1&paged=$2 [L]
-
RewriteRule ^tag/?(.*)/page/?(.*)/$ /index.php?tag=$1&paged=$2 [L]
-
-
# Tag feeds: "tag/TAGNAME/rss" => "wp-rss.php?tag=TAGNAME"
-
# "tag/TAGNAME/atom" => "wp-atom.php?tag=TAGNAME"
-
RewriteRule ^tag/?(.*)/feed/(feed|rdf|rss|rss2|atom)/?$ /index.php?tag=$1&feed=$2 [L]
-
-
RewriteCond %{REQUEST_FILENAME} !-f
-
RewriteCond %{REQUEST_FILENAME} !-d
-
RewriteRule . /index.php [L]
-
-
# END WordPress
My second problem was that I wanted to use /category/postname as permalink so the link /tag/tagname was detected as category "tag" and postname "tagname" by WP engine...
To fix this issue you need to edit ultimate-tag-warrior.php (I've use single-file release).
Find "ultimate_rewrite_rules" function (near 1550 line). Replace it with this one:
-
function ultimate_rewrite_rules($rules) {
-
if(get_option("utw_use_pretty_urls") == "yes") {
-
$baseurl = get_option("utw_base_url");
-
-
global $wp_rewrite;
-
-
$wp_rewrite->add_rewrite_tag('%tag%', '(.*)', 'tag=');
-
-
// without trailing slash
-
$rules_tmp += $wp_rewrite->generate_rewrite_rules($baseurl . '%tag%');
-
// with trailing slash
-
$rules_tmp += $wp_rewrite->generate_rewrite_rules($baseurl . '%tag%/');
-
-
}
-
return $rules;
-
}
Now make your .htaccess NOT writable (chmod 644).
Then goto Admin->Options->Permalink and click "Update Permalink Structure" - this will rebuild internal rewrite rules...
I want to say again: this is my first contact with WordPress code. Just want to help you.
How to use UltimateTagWarrior in WordPress 2.2.1 : XianSi ’s Blog Says:
[...] http://quark.qpsmod.net/coding/ultimate-tag-warrior-fix-for-wordpress-221 [...]
Jul 24, 2007, 20:18How to use UltimateTagWarrior in WordPress 2.2.1 : XianSi Blog Says:
[...] http://quark.qpsmod.net/coding/ultimate-tag-warrior-fix-for-wordpress-221 [...]
Jul 24, 2007, 12:24XianSi ’s Blog » Blog Archive » How to use UltimateTagWarrior in WordPress 2.2.1 Says:
[...] http://quark.qpsmod.net/coding/ultimate-tag-warrior-fix-for-wordpress-221 [...]
Jul 24, 2007, 10:07