[wp-hackers] How to create a custom url with extra delimiter?

Bjorn Wijers burobjorn at gmail.com
Thu Dec 3 15:30:39 UTC 2009


Hi,

I have the following working non pretty urls url:

http://site.dev/?pagename=somepage&myfilter=filtervalue&paged=1

And I would like to rewrite this to:

http://site.dev/somepage/myfilter/filtervalue/page/1

The filtervalue may also exists as a page title, therefor I need to add
the myfilter part in the url. I need pagination to work as well.

I'm pulling my hair out, since none of the regex I tried seem to work.
My last attempt, which is called by the action:

add_action('generate_rewrite_rules', '_my_add_rewrite_rules');

[code]
function _my_add_rewrite_rules( $wp_rewrite ) {
  $new_rules = array(
    'somepage/myfilter/(.+)' =>
    'index.php?pagename=somepage&myfilter=' .
     $wp_rewrite->preg_index(1) );

  $wp_rewrite->rules = $new_rules + $wp_rewrite->rules;
}
[/code]

Any help would be much appreciated!

-- 

met vriendelijke groet,
Bjorn Wijers

* b u r o b j o r n .nl *
digitaal vakmanschap | digital craftsmanship

Concordiastraat 68-126
3551 EM Utrecht
The Netherlands

phone: +31 6 49 74 78 70
http://www.burobjorn.nl


More information about the wp-hackers mailing list