Creating multiple permalinks for Authors
-
Ideally I’d like to set up rules where specific authors marked as scholars in the CMS will get the /scholar/nicename url and everyone else fall under the /profile/nicename url. I am not sure if this is doable so instead I am trying to make both URLs useable for all authors then write a function to build author URLs so throughout the site every where a scholar link shows up it gets the /scholar/ permalink and everyone else gets /profile/. In addition I will also add logic on the author template to redirect to the appropriate URL.
I also tried to establish multiple author bases but below code did not work, I tried some other variations but nothing seemed to work.
$wp_rewrite->author_base('profile|scholar');Below is my filter on the author rewrites, this is causing many problems and the site’s permalinks to completely break and points everything back to the homepage. Any help with the below code to achieve my goals or a completely different strategy to solve the problem would be much appreciated.
add_filter('author_rewrite_rules', 'new_author_base'); public function new_author_base(){ $author_rewrite = array(); $author_rewrite["profile/([0-9a-zA-Z-]+)/?$"] = 'index.php?author_name=$matches[1]'; $author_rewrite["scholar/([0-9a-zA-Z-]+)/?$"] = 'index.php?author_name=$matches[1]'; return $author_rewrite; }
The topic ‘Creating multiple permalinks for Authors’ is closed to new replies.