Change blog and category url ( page/2)

When I am on the blog, or category page, clicking on pagination for next page I get URL mydomain.com/blog/page/2 and the same for category /blog/category/page/2.

How to change that to remove “page” from URL. More to be like blog/category/2

Hello @pavlito,

Thanks for writing in! Regretfully the /page/ in the permalink is a WordPress default. You cannot remove it. It will result in an error 404 if you do so.

Regards.

@ruenel Thanks.

So it means, the /page/ should remain as it is.

Can I at least translate it?

Hi @pavlito,

You can change the pagination base word by adding the following code into your child theme’s functions.php

function custom_page_url_word() 
{
    global $wp_rewrite;
    $wp_rewrite->pagination_base = 'strona';
    unset($wp_rewrite->extra_rules_top["shop/page/([0-9]{1,})/?$"]);
    $wp_rewrite->extra_rules_top['shop/strona/([0-9]{1,})/?$'] = 'index.php?post_type=product&paged=$matches[1]';
}
add_action( 'init', 'custom_page_url_word' );

Please remember that the above code will work if copied as it is and don’t conflict with any existing style.
Please note that the code provided serves only as a guide to help you get started custom coding on your own if there’s no option offered in our theme or the products we bundle.
We really do not provide support for custom codes that means we can’t fix it in case it conflicts with something on your site nor will we enhance it.

You can also go through the following article, which may help you with this.

Thanks

Thank you on answers.

I used the example from the StackOverflow link, and it is working fine.

Glad to hear that, @pavlito!

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.