-
-
Save lauhakari/5089252 to your computer and use it in GitHub Desktop.
<?php | |
add_action( 'init', 'my_custom_page_word' ); | |
function my_custom_page_word() { | |
global $wp_rewrite; // Get the global wordpress rewrite-rules/settings | |
// Change the base pagination property which sets the wordpress pagination slug. | |
$wp_rewrite->pagination_base = "new-slug"; //where new-slug is the slug you want to use ;) | |
} |
Your code works for the pagination on homepage.
Do you have an idea about how to change the slug even for category pagination?
Works fine with 4.9.4.
And a heads-up: You need to save your permalinks to make this work.
Hey, this works on standard posts, but not on custom post type (gives 404 - als ofter saving permalinks), any way to make ot work for CPT? also is there a way to lose the sug completly (like domain.com/customcat/2 ) now when i live new slug blank i get "//" ( domain.com/postcat//2.
thanx
Had the same problem, for me the pagination doesn't work for WooCommerce, but after checking all rewrite rules I found out that the permalink structure for WooCommerce is not using pagination_base at all, so find the extra_rules_top rule that has "page" in it and reuse the rewrite rule like this:
unset($wp_rewrite->extra_rules_top["eshop/page/([0-9]{1,})/?$"]);
$wp_rewrite->extra_rules_top['eshop/new-slug/([0-9]{1,})/?$'] = 'index.php?post_type=product&paged=$matches[1]';
Ah is there anyway to strip the / before the page number? I am trying to re-write to /?=page_2/ and this method drops a / before the 2.
Well it works fine!!!
This is great, I am using on my home page with the slug home/page but have only just realized that it doesn't work on other pages with pagination. End up with a 404.
I tried adding if is_home
but that broke the function entirely. Probably because that if statement doesn't work from the functions.php? I don't know....
Is there any way to have this affect only the home page?
Thanks!
@saladgoat Yeah, not sure you can (easily) have different pagination_base's for different sections.
I believe that pagination_base
is more used to change the base path on the whole site. :)
@lauhakari I was afraid of that, but trying to be optimistic, thought I'd ask people who know way more about this than me....
Hey.
Sorry I haven't answered earlier, haven't seen your question. Can't really remember when or how I used this, prpably should've made a note to myself :P
Anyway, you can check whats in your current rewrite rules if your do this:
Maybe you can find the paginate property there? :)