[wp-hackers] How to create a custom url with extra delimiter?
Anthony Cole
me at anthony.geek.nz
Thu Dec 3 15:33:58 UTC 2009
Have you registered your query_vars? all GETs are stripped out of rewritten urls, just fyi.
You need to do something like this...
function bell_queryvars( $vars ) {
$vars[] = 'myfilter';
return apply_filters('bell_vars', $vars);
}
add_filter('generate_rewrite_rules', 'bell_add_rewrite');
-ac
On 4/12/2009, at 4:30 AM, Bjorn Wijers wrote:
> 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
> _______________________________________________
> wp-hackers mailing list
> wp-hackers at lists.automattic.com
> http://lists.automattic.com/mailman/listinfo/wp-hackers
More information about the wp-hackers
mailing list