- This topic has 25 replies, 3 voices, and was last updated 2 years, 11 months ago by Tom.
-
AuthorPosts
-
February 1, 2020 at 12:12 pm #1151596Carlo
Hi,
the author page at the moment isnt too customizable, is it possible to create a page and use that as the author(s) page. Basically replacing the author’s archive with a custom page?
February 1, 2020 at 2:03 pm #1151650LeoStaffCustomer SupportHi there,
GP doesn’t have anything built-in for this.
Perhaps an article like this would help?
https://www.wpbeginner.com/wp-themes/how-to-add-a-custom-author-profile-page-to-your-wordpress/February 1, 2020 at 11:39 pm #1151825CarloIs it possible to completely replace it with a static page, like the example in Toms WP Show Posts: https://docs.wpshowposts.com/article/use-static-pages-as-category-archives/
February 2, 2020 at 10:52 am #1152285TomLead DeveloperLead DeveloperYou could try this:
add_filter( 'author_link', function( $link, $author_id ) { if ( 1 === $author_id ) { return 'URL TO YOUR AUTHOR PAGE'; } if ( 2 === $author_id ) { return 'URL TO ANOTHER AUTHOR PAGE'; } return $link; }, 10, 2 );
Just adjust the author IDs to the actual IDs you’re targeting.
Hope this helps 🙂
February 4, 2020 at 12:20 am #1153681CarloCheers Tom,
Got that working well, so in essence, this code overrides all the author links to whatever we set for each author.
if i manually lookup site.com/author/”authorname”/ then the archive is still there but i guess they wont find it. any way to disable it?
February 4, 2020 at 8:12 am #1154347TomLead DeveloperLead DeveloperIf you’re using Yoast SEO, this should help: https://kb.yoast.com/kb/disable-enable-author-archives/
If not, this might help: https://wordpress.org/plugins/disable-author-archives/
February 8, 2020 at 10:08 am #1159013Carlothanks Tom, hadn’t thought of looking at other plugins for disabling the author archive. I use SEOPress instead and i found the same diable feature.
Anyway got it all working now 🙂
thanksFebruary 8, 2020 at 8:48 pm #1159294TomLead DeveloperLead DeveloperAwesome, no problem! 🙂
February 10, 2020 at 8:32 pm #1161286DanaHi GP Team,
I tried using the same info above to also override the default archive.php for author archive. However in my Elements I’m using the
{{post_author}}
tag and despite disabling the author archive page via Yoast, author links still point to //website.com/author/author-name but brings me to the root of the site if I click on the author since I disabled author archives. I’m using Example 2 from the documentation for my Element.How would I go about getting the
{{post_author}}
tag to point to my custom author pages? Or should it be automatically going to my custom author pages with the filter above? Perhaps using an actual author.php file would be better in this case?Thanks.
February 11, 2020 at 9:11 am #1162109TomLead DeveloperLead DeveloperJust to confirm, are you using this filter?: https://generatepress.com/forums/topic/custom-autor-page/#post-1152285
Have you updated the author ID? That filter should work for the Elements post author as well.
February 11, 2020 at 7:36 pm #1162436DanaThanks for the reply Tom.
Correct. I am using https://generatepress.com/forums/topic/custom-autor-page/#post-1152285.
I think I’m just not understanding the author ID piece. From my dashboard I go to Users and then hover over the number in the Posts column of the Users table. This shows me //mywebsite.com/wp-admin/edit.php?author=1. I only have two authors so they are 1 and 2 respectively.
I’m reading …
if ( 1 === $author_id )
… with the number 1 being the author ID. Is this correct?February 12, 2020 at 6:18 am #1162834DavidStaffCustomer SupportI’m reading …if ( 1 === $author_id )… with the number 1 being the author ID. Is this correct?
That is correct
February 12, 2020 at 10:10 am #1163279DanaThanks David. Interesting. Then my author ID’s are correct in this case yet hovering over the author name in a post which has an Element Header still shows //mywebsite.com/author/author-name. My posts are created in Elementor but I do not think that would mess with my Element Header, would it?
I did a random search on my site and the author name in the search results shows //mywebsite.com/author-name which is the expected outcome.
Seems like the filter is not liking the Element Header
{{post_author}}
tag? I’m using the code from the example here for my Element Header.February 12, 2020 at 5:24 pm #1163591TomLead DeveloperLead DeveloperI just double-checked our code – we’re using the core function which the
author_link
filter applies to.Wonder what this could be.. maybe the action order is off..
It’s a shot in the dark, but try this:
add_action( 'wp', function() { add_filter( 'author_link', function( $link, $author_id ) { if ( 1 === $author_id ) { return 'URL TO YOUR AUTHOR PAGE'; } if ( 2 === $author_id ) { return 'URL TO ANOTHER AUTHOR PAGE'; } return $link; }, 10, 2 ); }, 50 );
February 16, 2020 at 8:32 pm #1167591DanaThanks Tom. I gave that a shot but no go.
Any other ideas?
Maybe creating custom author pages would be a better route in this case?
-
AuthorPosts
- You must be logged in to reply to this topic.