WordPress add rewrite URL look like WPML

Same as title, i want visit link:

mysite.domain/hello-word
mysite.domain/my_slug/hello-word

is same link, look like WPML:

Read More
mysite.domain/hello-word
mysite.domain/en/hello-word

I try:

function custom_rewrite_tag() {
    add_rewrite_rule('^([^/]*)/?/([^/]*)/?', 'index.phptheme_var=$matches[0]&pagename=$matches[1]', 'top');
    add_rewrite_tag('%theme_var%', '([^&]+)');
}

add_action('init', 'custom_rewrite_tag', 10, 0);

but not working, somebody can help me?

Related posts

Leave a Reply

1 comment

  1. Do you forgot question sign?

    add_rewrite_rule('^([^/]*)/?/([^/]*)/?', 'index.php?theme_var=$matches[0]&pagename=$matches[1]', 'top');
    

    Between index.php and theme_var