Last active
December 28, 2021 01:07
-
-
Save lauhakari/5089252 to your computer and use it in GitHub Desktop.
Change the pagination url in Wordpress (3+) You can put in a plugin file or your functions.php.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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 ;) | |
} |
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....
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.