[wp-hackers] Options for Controller - Views

scribu scribu at gmail.com
Fri Nov 20 16:22:47 UTC 2009


>
> Sweet Jebus, man. Why in the *world* would you need all that?
>
> function add_product_var($public_query_vars) {
>    $public_query_vars[] = 'product';
>    return $public_query_vars;
> }
> add_filter('query_vars', 'add_product_var');
>
> function do_product_rewrite() {
>    add_rewrite_rule('product/([^/]+)/?$',
> "index.php?product={$matches[1]}",'top');
> }
> add_action('init', 'do_product_rewrite');
>


Even shorter:

function do_product_rewrite() {
        $tag = 'product';
        add_rewrite_tag("%$tag%", '([^/]+)', "$tag=");
        add_permastruct($tag, 'products' . "/%$tag%");
}
add_action('init', 'do_product_rewrite');


-- 
http://scribu.net


More information about the wp-hackers mailing list