- This topic has 7 replies, 2 voices, and was last updated 2 years, 3 months ago by
David.
-
AuthorPosts
-
September 28, 2019 at 9:11 am #1021351
Paul
Hello,
I want to change the author URL from the default location to a location specified by me. I currently have a 301 in place to achieve this but would like to remove the redirect hop and have it “hard coded”.
Please let me know if this is possible.
Thanks Paul
September 28, 2019 at 10:21 am #1021383David
StaffCustomer SupportHi there,
you can use the PHP filter provided here:
https://docs.generatepress.com/article/generate_post_author_output/#custom-author-name
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/October 1, 2019 at 8:26 am #1023481Paul
Thanks David – how would I adapt this for a multi author site. I don’t have a huge amount of authors so do I just repeat the function with each author specified? If so could you provide the correct syntax
October 1, 2019 at 11:41 am #1023639David
StaffCustomer SupportLittle more complicated – try this instead:
add_filter( 'author_link', 'switch_author_links', 10, 2); function switch_author_links( $url, $user_id) { switch($user_id) { case "100": return home_url( 'author_slug_1'); break; case "200": return home_url( 'author_slug_2'); break; case "300": return home_url( 'author_slug_3'); break; } return $url; }
Create a
case
for each author ID and return thepage_slug
for that author.Example:
case "100": return home_url( 'author_slug_1');
Author ID of
100
will have a link ofmywebsite.com/author_slug_1
You can get each Author ID by going to Users > All users and hovering over the number of Posts they have created, the link at the foot of the browser will include the ID.
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/October 2, 2019 at 7:31 am #1024260Paul
worked a treat. Thanks.
October 2, 2019 at 7:48 am #1024288David
StaffCustomer SupportAwesome – glad to be of help
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/October 31, 2020 at 5:35 am #1512140Edouard
Hi,
I would like to do the same change the author URL link but for the example 1 in your doc https://docs.generatepress.com/article/entry-meta-style/?fbclid=IwAR10g-fIphMWMjY9wDMJy8WIy5owvmT1LW6cwolfClAJ_H8XlCLdLRpF4Kg.
thanks for your help.
October 31, 2020 at 6:32 am #1512183David
StaffCustomer SupportHi there,
if you follow the steps in the doc:
Then add the code i provided here with your own IDs and Slugs:
https://generatepress.com/forums/topic/change-author-url/#post-1023639
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/ -
AuthorPosts
- You must be logged in to reply to this topic.