Support » Plugins » 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

    which should work.

Ansicht von 1 Antwort (von insgesamt 1)
  • Moderator Bego Mario Garde


    Moderation Note:

    I have closed this thread because you asked your question in English in the German support forums. To keep the threads accessible for users who don’t speak English, please ask your question in German or post it in the international support forums.

    Please also consider asking your question at WordPress Stackexchange as this usually is a better place to get answers to questions about programming themes and plugins.

    Thanks for your understanding.

Ansicht von 1 Antwort (von insgesamt 1)
  • Das Thema „rewriteRules WP6“ ist für neue Antworten geschlossen.