Site logo

Archived topic

changing author base slug

3 replies · Started by Chris on September 20, 2022

Viewing posts 1–4 of 4

Hi,

I'd like to change the /author/ base slug to /journalist/

I found the following code to do that:

//change /author/ slug to /journalist/ 
function new_author_base() {
    global $wp_rewrite;
    $myauthor_base = 'journalist';
    $wp_rewrite->author_base = $myauthor_base;
}
add_action('init', 'new_author_base');

that seems simple enough and works on all of the author links in the bylines, bios and such.

However, the permalink for the author pages are still site.com/author/name. I get a 404 page if I access site.com/journalist/name

I've resaved permalinks and cleared caches.

Should the code snippet have reset the permalink to /journalist/ ? If so, thoughts on why it isn't working?

Thanks,

Chris

Hi Chris,

The code looks correct, it should achieve what you are looking for.

But the theme doesn't handle permalinks, I don't think there's anything we can offer regarding this issue.

I would suggest disabling all your plugins to test, in case there are any of them altering permalinks.

Oh, ooooh... I got it :)

After you confirmed it should be working... I got to thinking, what could be going wrong...

Then I thought - I might have code snippets set to run that snippet on the front end... I wonder if... yep - switched it to working 'everywhere', resaved the permalink settings - and presto, now it is working as expected.

Thanks, it was you saying it should work that got the wheels turning in my head :)

Chris

Awesome :)

Glad it's working now!

This archived topic is closed to new replies.