rewriteRules WordPress 6.x | ProjectDMC.org Deutsch

[ad_1]

Hallo,

ich habe in meinem Plugin einen custom post type, den ich so definiere:

$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 );

mit dieser function habe ich bisher in WP5 die Umleitungsregeln ergänzt. Nun funktioniert es nicht mehr seit WP6. Ich habe die Function debugged und stelle fest, das WP sie nicht mehr durchläuft.

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' );

Zudem testete ich diesen Filter ohne Erfolg.

add_filter(‚rewrite_rules_array‘,’……………

Der Slug, den ich für den cpt aufbaue ist:

Kann jemand bitte unterstützen?

[ad_2]

 

This site will teach you how to build a WordPress website for beginners. We will cover everything from installing WordPress to adding pages, posts, and images to your site. You will learn how to customize your site with themes and plugins, as well as how to market your site online.

Buy WordPress Transfer