• Hello!

    I want to change the URL for the pages in my shop. Everything else, besides the pages is in Slovenian, which makes the “- Page 2” for example look weird.

    You can see both things I want to change right here. I want the tab to say Trgovina – Moj Bazen – Stran 2 and the URL to be [ redundant link removed ] instead of what it’s shown in the screenshot.

    Kind regards

    • This topic was modified 2 years, 3 months ago by Jan Dembowski. Reason: Moved to Fixing WordPress, this is not an Developing with WordPress topic

    The page I need help with: [log in to see the link]

Viewing 13 replies - 1 through 13 (of 13 total)
  • Hello jazzu,

    In the tab area, it showcases the text based on the site language that you have selected.

    Please check your current site language and change it to Slovenian and it will work as expected.

    For the settings check the below screenshot to get an idea that how it works.

    Click here to review the screenshot for the settings.

    Hope this helps.

    Thank you,
    Hitendra

    Thread Starter jazzu

    (@jazzu)

    Hi @hitendra-chopda !

    Thank you for your reply. One problem – the site is set to Slovenian.

    Screenshot

    Kind regards

    Okay @jazzu

    Then it might be a wordpress translation issue or another issue. Are you using the latest version of wordpress?

    I have tested the latest wordpress version with the Storefront theme and it’s working great for me.

    If you are using another language wordpress pack then it might not be showing there

    Like, you can download the wordpress in different languages like your language pack is download from here – https://sl.wordpress.org/download/

    Thank you,
    Hitendra

    Thread Starter jazzu

    (@jazzu)

    Hi!

    No, everything else is working great. I have the latest version of WordPress.

    I tried to find the word “Page” in Loco translate too. I was searching in theme and plugins files, but no luck.

    Kind regards

    I think this may help you:
    https://wordpress.stackexchange.com/questions/57070/change-the-page-slug-in-pagination

    It seem than this piece of code could help

    function my_change_rewrite_base() {
        global $wp_rewrite;
        $bases = array(
            'author' => __('Author'), 
            'search' => __('Search'), 
            'comments' => __('Comments)', 
            'pagination' => __('Page')
        );
    
        foreach ($bases AS $key => $base) {
            $wp_rewrite->{$key} = remove_accents(mb_strtolower($base));
        }
    
        if ( ! get_option('my_change_rewrite_base_flushed', false) ) {
            flush_rewrite_rules();
            update_option( 'my_change_rewrite_base_flushed', time());
        }
    }
    add_action('init', 'my_change_rewrite_base');
    Thread Starter jazzu

    (@jazzu)

    Hi @perezdans !

    Thank you for replying.

    I added the code to functions.php. Changed it to what I want it to be, but it didn’t do anything.

    function my_change_rewrite_base() {
        global $wp_rewrite;
        $bases = array(
            'author' => __('Avtor'), 
            'search' => __('Iskanje'), 
            'comments' => __('Komentarji'), 
            'pagination' => __('Stran')
        );
    
        foreach ($bases AS $key => $base) {
            $wp_rewrite->{$key} = remove_accents(mb_strtolower($base));
        }
    
        if ( ! get_option('my_change_rewrite_base_flushed', false) ) {
            flush_rewrite_rules();
            update_option( 'my_change_rewrite_base_flushed', time());
        }
    }
    add_action('init', 'my_change_rewrite_base');

    After that I tried with Code Snippets plugin and got this error:

    The snippet has been deactivated due to an error on line 2:
    
    Cannot redeclare function my_change_rewrite_base.

    Kind regards

    Hi,

    I tried this code and it’s working:

    function re_rewrite_rules() {
        global $wp_rewrite;
        // $wp_rewrite->author_base = $author_slug;
    //  print_r($wp_rewrite);
        $wp_rewrite->author_base        = 'avtor';
        $wp_rewrite->search_base        = 'iskanje';
        $wp_rewrite->comments_base      = 'komentarji';
        $wp_rewrite->pagination_base    = 'stran';
    	if ( ! get_option('my_change_rewrite_base_flushed', false) ) {
            $wp_rewrite->flush_rules();
            update_option( 'my_change_rewrite_base_flushed', time());
        }
        
    }
    add_action('init', 're_rewrite_rules');

    Put it on your functions.php or with code snippets plugin but not with both or you will get “Cannot redeclare function my_change_rewrite_base” error

    Thread Starter jazzu

    (@jazzu)

    Hi @perezdans !

    Thank you for your reply.

    I tried adding it via code snippets. The URL, when I hover over the page numbers in the shop displays correctly. Screenshot

    However, if I click the page, it leads to some weird page with only like 5% of some random product. The URL changes too. You can see that here.

    Kind regards

    Please, active code again and the go to settings / permalinks and save without changing anything

    I think thats the problem

    Thread Starter jazzu

    (@jazzu)

    Hi @perezdans !

    I did what you said. The URL is correct when I hover over the page number, but now, it just sends me to the homepage.

    Hi:

    I created this test WP
    https://testpaging.us4.instawp.xyz/category/gutenberg/

    I installed Code Snippets with the given code and created four posts. As you can see, pagination is working as needed (https://testpaging.us4.instawp.xyz/category/gutenberg/stran/2/)

    Try again with this minor change in your code. Test it from a private browser:

    function re_rewrite_rules() {
        global $wp_rewrite;
        $wp_rewrite->author_base        = 'avtor';
        $wp_rewrite->search_base        = 'iskanje';
        $wp_rewrite->comments_base      = 'komentarji';
        $wp_rewrite->pagination_base    = 'stran';
    	if ( ! get_option('my_re_rewrite_rules_flushed', false) ) {
            $wp_rewrite->flush_rules();
            update_option( 'my_re_rewrite_rules_flushed', time());
        }
        
    }
    add_action('init', 're_rewrite_rules');
    Thread Starter jazzu

    (@jazzu)

    Tried it again. Sends me to the homepage again. I did go and check Redirections plugin and found this in 404 tab: Screenshot

    Kind regards

    Hello,

    As i said, code is working properly. You can have a look at the test WordPress i created:
    https://testpaging.us4.instawp.xyz/wp-admin/
    User: testpaging
    Pass: oIIYcKij

    Maybe there is an issue with an installed plugin o with your browser cache. Try to deactivate your plugins and check again.

Viewing 13 replies - 1 through 13 (of 13 total)
  • The topic ‘Translating page number URL’ is closed to new replies.