0

Simply put, I have a page called 'products' (not a post, but a page, not to confuse). Which is perfectly accessable through:

domein.com/products/

On this page it shows the template matched with the page 'products'. So far so good, this is basic wordpress.

Now, on that page I have post categories listed. I want to put the categories listed on that page in my permalink like this:

domein.com/products/category_slug

This currently gives a 404, fair enough, it is not a page. However, I want wordpress to show the template of the 'products' page and it need to pass along the category_slug as a variable so I can process it in the template of products.

Problem is that I have tried to adjust the htaccess file but I don't seem to be able to figure out where in wordpress I need to make these changes. I tried:

RewriteEngine On
RewriteBase /
RewriteRule ^products/(.*) /index.php/products?cat=$1
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)$ /index.php/$1

But this doesn't work. Anybody any suggestions or any direction where to start looking? Do I need to change this in the htaccess file or is there a php engine file that processes these things? Thanks in advance

4

1 に答える 1

1

anwser を探している人は、wordpress にフックがあることがわかりました。

add_filter('rewrite_rules_array','function_name');

function function_name($rules) {
    $new_rules['url_to_rewrite'] = 'index.php?pagename=pagename';

    return $new_rules + $rules;
}
于 2012-05-10T08:39:50.867 に答える