Forum Replies Created

Viewing 4 replies - 1 through 4 (of 4 total)
  • hi all.
    I also have the same proplem.
    When my page in english language, get_term_link work fine. Link is: https://homepage/category/drill. But when page in vietnamese language, get_term_link work wrong, link is : https://homepage/vi/vi/category-vi/drill-vi.
    I don’t know why :((. help me

    Hi uilhao. I added function.php file the following code:

    add_filter('wp_loaded','flushRules');
    
        // Remember to flush_rules() when adding rules
        function flushRules(){
                global $wp_rewrite;
                $wp_rewrite->flush_rules();
        }

    But… It hasn’t worked yet.
    I don’t know why :((.
    Do you have other solutions?

    Hi kkirsche. what did you do to fix it. May you share your solution for me? I haven’t fixed it yet. :((
    This is my code :

    remove_filter('template_redirect', 'redirect_canonical');
        /*Custom url rewrite */
        function mechanical_rules( $rewrite_rules ) {
            $new_rules = array(
                '^category/([^/]*)/brand/([^/]*)/.html$' => 'index.php?pagename=products&cate=$matches[1]&br=$matches[2]'
               ,'^brand/([^/]*)/category/([^/]*)/.html$' => 'index.php?pagename=products&br=$matches[1]&cate=$matches[2]'
    
                );
            $rewrite_rules = $new_rules + $rewrite_rules;
            return $rewrite_rules;
        }
        add_filter('rewrite_rules_array', 'mechanical_rules');
    
        add_filter('query_vars', 'mechanical_query_vars');
        function mechanical_query_vars($public_query_vars) {
            $public_query_vars[] = 'cate';
            $public_query_vars[] = 'br';
            return $public_query_vars;
        }

    :(( help me, i haven’t do it yet. uilhao, help me. I added your code line in function.php file, but it don’t work. this is my code:

    remove_filter('template_redirect', 'redirect_canonical');
        /*Custom url rewrite */
        function mechanical_rules( $rewrite_rules ) {
            $new_rules = array(
                '^category/([^/]*)/brand/([^/]*)/.html$' => 'index.php?pagename=products&cate=$matches[1]&br=$matches[2]'
               ,'^brand/([^/]*)/category/([^/]*)/.html$' => 'index.php?pagename=products&br=$matches[1]&cate=$matches[2]'
    
                );
            $rewrite_rules = $new_rules + $rewrite_rules;
            return $rewrite_rules;
        }
        add_filter('rewrite_rules_array', 'mechanical_rules');
    
        add_filter('query_vars', 'mechanical_query_vars');
        function mechanical_query_vars($public_query_vars) {
            $public_query_vars[] = 'cate';
            $public_query_vars[] = 'br';
            return $public_query_vars;
        }

Viewing 4 replies - 1 through 4 (of 4 total)