rewriteRules WP6
-
I’ve got a custom post type „products“ which is set up this way
$args_products = array(
'labels' => array('name'=> 'Product Category'),
'public' => true,
'menu_icon' => 'dashicons-products',
'supports' => array(
'title', 'editor', 'author', 'thumbnail', 'excerpt', 'revisions', 'page-attributes',
),
'has_archive' => true,
'hierarchical' => true,
'rewrite' => array(
'slug' => sprintf( '%s/&products_categories&', 'products' ),
'with_front' => false,
),
);register_post_type( 'products', $args_products );
an following rewriteRules function, which in WP6 does not work anymore. I already debugged but WP is not running through.
function products_rewrite_rule( $rules ) {
$newRule1 = sprintf( '%s/([^/]+)/(?:(?!\bpage\b).)+/([^/]+)/?$', 'products' ); // matches products (products) but let WordPress do taxonomy pagination stuff correctly
$newRule2 = sprintf( '%s/([^/]+)/([^/]+)/(?:(?!\bpage\b).)+/([^/]+)/?$', 'products' );
$newRules = array();
$newRules[$newRule1] = 'index.php?products=$matches[2]';
$newRules[$newRule2] = 'index.php?products=$matches[3]';
$rules->rules = $newRules + $rules->rules;
}
add_filter( 'generate_rewrite_rules', 'products_rewrite_rule' );also tried this add_filter(‚rewrite_rules_array‘,’……………
The Slug is made of multiple categories for example https://domain.com/products/cat1/subcat2/productname/
which should work.
- Das Thema „rewriteRules WP6“ ist für neue Antworten geschlossen.