Change author & pagination base in WordPress

By default, the pagination base used in archives permalinks is set to /page/. Similarly, the author permalink base is set to /author/. In this short article, I will present you an easy way to adjust both the pagination & author permalinks in WordPress.

What are the rewrite rules?

Every permalink should match one of the URL patterns named rewrite rules. WordPress uses them to detect what content type should be loaded. Therefore, for each post type and taxonomy a unique rewrite rule (permalink format) should be defined.

To explain how they work, let’s see some simple example. You can find the full list of sample rewrite rules here. The rewrite rules are defined also for archive pages. For author archive pages they should look like this:

author/([^/]+)/feed/(feed|rdf|rss|rss2|atom)/?$
author/([^/]+)/(feed|rdf|rss|rss2|atom)/?$
author/([^/]+)/page/?([0-9]{1,})/?$
author/([^/]+)/?$

As you can see, they are based on regular expressions (REGEX) formulas. Each of them is actually a pattern containing capturing group and text strings. The patterns posted above contain three different capturing groups:

  • ([^/]+) is used to get the author slug (eg. john-doe) from requested URL
  • (feed|rdf|rss|rss2|atom) is used to get the feed type (eg. feed) from requested URL
  • ([0-9]{1,}) is used to parse the page number (eg. 2) from requested URL

And two rewrite bases:

  • author
  • page

The following URLs will be parsed and recognized as author archive permalinks:

https://example.com/author/john-doe/feed/rss/
https://example.com/author/john-doe/feed/
https://example.com/author/john-doe/page/2/
https://example.com/author/john-doe/

How to change the rewrite bases?

There are many reasons why you would like to change the rewrite bases. For instance, you may need to translate either author or page to your language. Of course, you can simply change them to any word you like.

Below you will find two code snippets that would allow you to change the rewrite bases for both author archive and pagination URLs. Please keep in mind that every time you adjust them, you will need to make WordPress flush the rewrite rules to apply the changes.

This feature is not available in Permalink Manager, so to use it you will need to customize the following code snippets & paste them to functions.php file in (child) theme directory. Alternatively, you can use 3rd party plugin such as Code Snippets to enter the code.

The pagination base (all archive permalinks)

Sample archive permalink before the change:

https://example.com/2019/10/page/2/
https://example.com/blog/page/2/
https://example.com/shop/apparel/shirts/page/2/

function pm_change_pagination_base() {
	global $wp_rewrite;
	
	$wp_rewrite->pagination_base = 'seite';
}
add_action('init', 'pm_change_pagination_base');

Sample archive permalink after the change:

https://example.com/2019/10/seite/2/
https://example.com/blog/seite/2/
https://example.com/shop/apparel/shirts/seite/2/

The author base (author archives)

Sample author permalink before the change:

https://example.com/author/john-doe/
https://example.com/author/jan-kowalski/
https://example.com/author/ola-nordmann/

function pm_change_author_base() {
	global $wp_rewrite;
	
	$wp_rewrite->author_base = 'user';
}
add_action('init', 'pm_change_author_base');

Sample author permalink after the change:

https://example.com/user/john-doe/
https://example.com/user/jan-kowalski/
https://example.com/user/ola-nordmann/

How to flush the rewrite rules?

To flush the rewrite rules, you will need to login to your WordPress admin account and go to “Settings -> Permalinks” section. After you are there, you need to click on “Save Changes” button. The rewrite rules will be flushed and the new rewrite bases applied to either/both archive pagination & author page URLs.

Flush rewrite rules
The rewrite rules can be flushed in Permalink settings.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

*

*