I want the WooCommerce way to create new rules for permalinks. I have checked WooCommerce core files and found that WooCommerce is using this filter for saving the rule in database. My current url is http://amit.com/wcommerce/seller-login/?page=mpProfile. I have var dumped get_query_var('pagename'); on hit page, but hitting url shows blank. I want this url as http://amit.com/wcommerce/seller-login/mpProfile. Any one have any idea over this part? I have been stuck on this for around 3 days.

Here is my code:

    add_action( 'wp_loaded','my_flush_rules' );
    add_filter( 'rewrite_rules_array','my_insert_rewrite_rules' );
    add_filter( 'query_vars','my_insert_query_vars' );

    function my_flush_rules() {
        $rules = get_option( 'rewrite_rules' );

            if ( ! isset( $rules['(seller-login)/(.+)$'] ) ) {
                global $wp_rewrite;


    function my_insert_rewrite_rules( $rules ) { 
        $newrules = array();
        $newrules['(seller-login)/(\d*)$'] = 'index.php?pagename=$matches[1]';
        // var_dump($newrules);     
        return $newrules + $rules;

    function my_insert_query_vars( $vars ) {

        array_push($vars, 'pagename');

        return $vars;

things are working by using rewrite_rules_array filter 1 :- i want to know the difference between add_rewrite_url() and rewrite_rules_array filter also i want to add array of rules in rewrite_rules_array filter but currently its not working only one of the rule is working others are not thanks

  • I got fixed this issue someone nedd help you can comment here – Amit Chauhan Oct 6 '16 at 15:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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