0

Following is example of what we are looking for. We're trying this in wordpress and we require all parameters as a variable


Example 1 : http://example.com/tno/?parent=abc

Need this : http://example.com/tno/abc


Example 2 : http://example.com/tno/?parent=abc&sub1=abc&sub2=abc

Need this : http://example.com/tno/abc/abc/abc


funtion.php code OR .htaccess rule any suggestion.

Thanks in advance

4

2 Answers 2

0

Into wordpress function file add following code and check it.

add_filter('query_vars', function( $vars ){
    $vars[] = 'parent'; 
    return $vars;
});

function archive_rewrite_rules() {
    add_rewrite_rule(
    '^(.*)/(.*)/?$',
    'index.php?post_type=client&name=$matches[1]&parent=$matches[2]',
    'top'
    );

    add_rewrite_rule(
    '^(.*)/?$',
    'index.php?post_type=client&name=$matches[1]',
    'top'
    );
    //flush_rewrite_rules(); // use only once
}

add_action( 'init', 'archive_rewrite_rules' );
0

Simply, go to Dashboard Setting > Permalink and change to "Post name" link type or you can use a plugin like enter link description here And for redirect you can use this plugin: enter link description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.