Turning rewrite hack into plugin
-
I need some help turning a very simple rewrite.php hack into a plugin.
I want my feed, comment and search URLs to start with
$wp_rewrite->front
instead of$wp_rewrite->root
(so they’ll be accessible at/blog/feed/
instead of/feed/
, et cetera). This is easy to do with a hack; I simply change$this->root
to$this->front
in each ofget_search_permastruct()
,get_feed_permastruct()
andget_comment_feed_permastruct()
in rewrite.php.Obviously this is a crappy solution, but hours of trying to accomplish the same thing using filters has proven fruitless.
As an example, I’ve tried this:
function changeRootRewriteRules($rewrite) { global $wp_rewrite; $rewrite = $wp_rewrite->generate_rewrite_rules($wp_rewrite->front . '/', EP_ROOT); return $rewrite; } add_filter('root_rewrite_rules', 'changeRootRewriteRules');
I see the changes I’ve made when I
print_r( $wp_rewrite->rewrite_rules() )
:... [blog/feed/(feed|rdf|rss|rss2|atom)/?$] => index.php?&feed=$1 [blog/(feed|rdf|rss|rss2|atom)/?$] => index.php?&feed=$1 [blog/page/?([0-9]{1,})/?$] => index.php?&paged=$1 ...
But those rules don’t actually have an effect; my feeds are still only accessible at
/feed/
instead of/blog/feed/
.Help would be most appreciated.
- The topic ‘Turning rewrite hack into plugin’ is closed to new replies.