// Here is my plugin's init function, where it adds the endpoint: $langSwitchPermalink = "langswitch_lang"; function langswitch_init () { global $langSwitchPermalink; global $wp_rewrite; // this doesn't seem to work in global namespace add_rewrite_endpoint( $langSwitchPermalink, EP_PERMALINK + EP_DATE + EP_YEAR + EP_MONTH + EP_DAY + EP_ROOT + EP_COMMENTS + EP_SEARCH + EP_CATEGORIES + EP_AUTHORS + EP_PAGES ); $wp_rewrite->flush_rules(); } // The actual permalink sections are added with filters, e.g.: add_filter( 'the_permalink', 'langswitch_add_language_url' ); add_filter( 'post_link', 'langswitch_add_language_url' ); // Definition of that function (somewhat simplified -- the real version // does a lot more checking $langswitch_lang = "es"; function langswitch_add_language_url( $urlstr ) { global $langSwitchPermalink, $langswitch_lang; return langswitch_trailingslashit( $urlstr ) . $langSwitchPermalink . "/" . $langswitch_lang; } function langswitch_trailingslashit( $uri ){ if( $uri{ strlen($uri) - 1 } != '/' ) { return $uri . '/'; } else { return $uri; } } ///////////////////////////////// Here is a printout of the rewrite rules being generated, with the permalink set to /%category%/%postname%/ and a couple of pages present in the database. Current blog URL is http://poplarware.com/WPTest/ I also have a hack installed on that page that prints out which rule matched whenever you visit a link; the rewrite rules are also printed out at the top of every post. Here they are currently: robots.txt$ wp-atom.php$ wp-rdf.php$ wp-rss.php$ wp-rss2.php$ wp-feed.php$ wp-commentsrss2.php$ (another-page/about)/trackback/?$ (another-page/about)/feed/(feed|rdf|rss|rss2|atom)/?$ (another-page/about)/(feed|rdf|rss|rss2|atom)/?$ (another-page/about)/page/?([0-9]{1,})/?$ (another-page/about)/langswitch_lang(/(.*))?/?$ (another-page/about)(/[0-9]+)?/?$ another-page/about/attachment/([^/]+)/?$ another-page/about/attachment/([^/]+)/trackback/?$ another-page/about/attachment/([^/]+)/feed/(feed|rdf|rss|rss2|atom)/?$ another-page/about/attachment/([^/]+)/(feed|rdf|rss|rss2|atom)/?$ (another-page)/trackback/?$ (another-page)/feed/(feed|rdf|rss|rss2|atom)/?$ (another-page)/(feed|rdf|rss|rss2|atom)/?$ (another-page)/page/?([0-9]{1,})/?$ (another-page)/langswitch_lang(/(.*))?/?$ (another-page)(/[0-9]+)?/?$ another-page/attachment/([^/]+)/?$ another-page/attachment/([^/]+)/trackback/?$ another-page/attachment/([^/]+)/feed/(feed|rdf|rss|rss2|atom)/?$ another-page/attachment/([^/]+)/(feed|rdf|rss|rss2|atom)/?$ (test-static-post-page)/trackback/?$ (test-static-post-page)/feed/(feed|rdf|rss|rss2|atom)/?$ (test-static-post-page)/(feed|rdf|rss|rss2|atom)/?$ (test-static-post-page)/page/?([0-9]{1,})/?$ (test-static-post-page)/langswitch_lang(/(.*))?/?$ (test-static-post-page)(/[0-9]+)?/?$ test-static-post-page/attachment/([^/]+)/?$ test-static-post-page/attachment/([^/]+)/trackback/?$ test-static-post-page/attachment/([^/]+)/feed/(feed|rdf|rss|rss2|atom)/?$ test-static-post-page/attachment/([^/]+)/(feed|rdf|rss|rss2|atom)/?$ feed/(feed|rdf|rss|rss2|atom)/?$ (feed|rdf|rss|rss2|atom)/?$ page/?([0-9]{1,})/?$ comments/feed/(feed|rdf|rss|rss2|atom)/?$ comments/(feed|rdf|rss|rss2|atom)/?$ comments/page/?([0-9]{1,})/?$ search/(.+)/feed/(feed|rdf|rss|rss2|atom)/?$ search/(.+)/(feed|rdf|rss|rss2|atom)/?$ search/(.+)/page/?([0-9]{1,})/?$ search/(.+)/langswitch_lang(/(.*))?/?$ search/(.+)/?$ category/(.+?)/feed/(feed|rdf|rss|rss2|atom)/?$ category/(.+?)/(feed|rdf|rss|rss2|atom)/?$ category/(.+?)/page/?([0-9]{1,})/?$ category/(.+?)/langswitch_lang(/(.*))?/?$ category/(.+?)/?$ author/([^/]+)/feed/(feed|rdf|rss|rss2|atom)/?$ author/([^/]+)/(feed|rdf|rss|rss2|atom)/?$ author/([^/]+)/page/?([0-9]{1,})/?$ author/([^/]+)/langswitch_lang(/(.*))?/?$ author/([^/]+)/?$ ([0-9]{4})/([0-9]{1,2})/([0-9]{1,2})/feed/(feed|rdf|rss|rss2|atom)/?$ ([0-9]{4})/([0-9]{1,2})/([0-9]{1,2})/(feed|rdf|rss|rss2|atom)/?$ ([0-9]{4})/([0-9]{1,2})/([0-9]{1,2})/page/?([0-9]{1,})/?$ ([0-9]{4})/([0-9]{1,2})/([0-9]{1,2})/langswitch_lang(/(.*))?/?$ ([0-9]{4})/([0-9]{1,2})/([0-9]{1,2})/?$ ([0-9]{4})/([0-9]{1,2})/feed/(feed|rdf|rss|rss2|atom)/?$ ([0-9]{4})/([0-9]{1,2})/(feed|rdf|rss|rss2|atom)/?$ ([0-9]{4})/([0-9]{1,2})/page/?([0-9]{1,})/?$ ([0-9]{4})/([0-9]{1,2})/langswitch_lang(/(.*))?/?$ ([0-9]{4})/([0-9]{1,2})/?$ ([0-9]{4})/feed/(feed|rdf|rss|rss2|atom)/?$ ([0-9]{4})/(feed|rdf|rss|rss2|atom)/?$ ([0-9]{4})/page/?([0-9]{1,})/?$ ([0-9]{4})/langswitch_lang(/(.*))?/?$ ([0-9]{4})/?$ (.+?)/([^/]+)/trackback/?$ (.+?)/([^/]+)/feed/(feed|rdf|rss|rss2|atom)/?$ (.+?)/([^/]+)/(feed|rdf|rss|rss2|atom)/?$ (.+?)/([^/]+)/page/?([0-9]{1,})/?$ (.+?)/([^/]+)/langswitch_lang(/(.*))?/?$ (.+?)/([^/]+)(/[0-9]+)?/?$ .+?/[^/]+/([^/]+)/?$ .+?/[^/]+/([^/]+)/trackback/?$ .+?/[^/]+/([^/]+)/feed/(feed|rdf|rss|rss2|atom)/?$ .+?/[^/]+/([^/]+)/(feed|rdf|rss|rss2|atom)/?$ .+?/[^/]+/attachment/([^/]+)/?$ .+?/[^/]+/attachment/([^/]+)/trackback/?$ .+?/[^/]+/attachment/([^/]+)/feed/(feed|rdf|rss|rss2|atom)/?$ .+?/[^/]+/attachment/([^/]+)/(feed|rdf|rss|rss2|atom)/?$ (.+?)/feed/(feed|rdf|rss|rss2|atom)/?$ (.+?)/(feed|rdf|rss|rss2|atom)/?$ (.+?)/page/?([0-9]{1,})/?$ (.+?)/langswitch_lang(/(.*))?/?$ (.+?)/?$