permalinks – rewrite based slug standar post wp


I want to create based slug for default post type wordpress based on query var lang.
for lang=en my url want to be{post-name}

for lang=nl my url want to be{post-name}

here my code so far but somehow did not work, and show in query monitor

    function custom_rewriteRules( $rules ) {
    $new_rules = array(

        '(articles)/page/?([0-9]{1,})/?$'   => 'pagename=$matches[1]&paged=$matches[2]&lang=en',
        'articles/page/?([0-9]{1,})/?$'     => 'post_type=post&paged=$matches[1]&lang=en',
        'articles/([^/]+)(?:/([0-9]+))?/?$' => 'post_type=post&name=$matches[1]&page=$matches[2]&lang=en',

        '(artikelen)/page/?([0-9]{1,})/?$'   => 'pagename=$matches[1]&paged=$matches[2]&lang=nl',
        'artikelen/page/?([0-9]{1,})/?$'     => 'post_type=post&paged=$matches[1]&lang=nl',
        'artikelen/([^/]+)(?:/([0-9]+))?/?$' => 'post_type=post&name=$matches[1]&page=$matches[2]&lang=nl',
    return $new_rules + $rules; 
add_action( 'rewrite_rules_array', 'custom_rewriteRules' );

and do I need to set articles in custom structure permalink

Baim Quraisy 2 weeks 2021-11-17T23:48:13-05:00 0 Answers 0 views 0

Leave an answer