I want to change WooCommerce pagination links from:
I found many examples of how to change '/page/' to '/something/' but I want only the number of the current page. I also tried this:
$wp_rewrite->pagination_base = '';
But then my url looks like this:
example/category//3/
And that's not good either. Is it even possible to remove 'pagination base' from url structure?
I want to change WooCommerce pagination links from:
I found many examples of how to change '/page/' to '/something/' but I want only the number of the current page. I also tried this:
$wp_rewrite->pagination_base = '';
But then my url looks like this:
example.com/category//3/
And that's not good either. Is it even possible to remove 'pagination base' from url structure?
If you go into the control panel, into settings and then to the "Permalink"-section, you can simply put a "." in the category-base field, which will remove any additions made to the actual URL.
Alternatively: Did you even set a custom URL-structure for your permalinks? This is obviously the first
Disclaimer: I'm not sure it works for WooCommerce.
My answer is, its possible, however the only way I know is to customize woocommerce files and code something almost from scratch to use url to know the page is determined by the number. However this is something hard to achieve, but possible, this because something has to tell that is the second page, and 2 or 3 or 4 is the number of the page, the result. so a variable should be in place to set that, and that variable has to have a character. Other way and maybe the best one is to pass this variable in your php session, that its invisible to the user, and you can grab the info, this customizing the wc file. That said my advice for simplicity is to change your function variable
$wp_rewrite->pagination_base = 'custom-page-pagination';
to
$wp_rewrite->pagination_base = 'pg';
and the result will be example.com/category/pg/2/
its not what is intended, but if you can live with it, woocommerce will says thanks. and who cares anyway. right! but yes its possible, but you will need to change woocommerce files code to do so. you will need to customize some wc files.
category
is a placeholder, right? How should WP know if/category/3
is page 3 or a sub-category called3
(as that is the default URL for this case)? – kero Commented Oct 25, 2021 at 15:293
? The/page/
is there for a good reason to avoid these clashes. Why do you want to remove it? – Tom J Nowell ♦ Commented Oct 25, 2021 at 21:14