Archived topic
How To change link to Author page
13 replies · Started by Jodie on December 16, 2019
Hi guys
I’ve just checked the link that the author name directs to and it seems to be an archive page –
I want this link to direct to the About Page.
How can I do that please?
Cheers
Jodie
Hi there,
Do you only have one author in your blog?
Let me know :)
Yes it is just me at this stage :)
Try this PHP snippet:
add_filter( 'generate_post_author_output', function() {
printf( ' <span class="byline">%1$s</span>',
sprintf( '<span class="byline">%1$s<span class="author vcard" %5$s><a class="url fn n" href="https://LINK-TO-ABOUT-PAGE" title="%3$s" rel="author" itemprop="url"><span class="author-name" itemprop="name">%4$s</span></a></span></span> ',
apply_filters( 'generate_inside_post_meta_item_output', '', 'author' ),
esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ),
/* translators: 1: Author name */
esc_attr( sprintf( __( 'View all posts by %s', 'generatepress' ), get_the_author() ) ),
esc_html( get_the_author() ),
generate_get_microdata( 'post-author' )
)
);
} );
Adding PHP: https://docs.generatepress.com/article/adding-php/
Make sure to replace LINK-TO-ABOUT-PAGE with the actual link.
Thanks very much Leo.
I will try to do as you have suggested and get back to you.
Hi Leo
It is coming back with this error message for this line
generate_get_microdata( 'post-author' )
Your PHP code changes were rolled back due to an error on line 35 of file wp-content/themes/generatepress_child/functions.php. Please fix and try saving again.
syntax error, unexpected end of file, expecting ',' or ')'
What shall I do?
That's weird. I tested the code without any issues:
https://www.screencast.com/t/MrdcweIEmazk
What happens if you remove your other functions?
Thank you Leo
I was missing some of the code I realise now.
What happens to that author page that the link was originally linking to?
Where is that now?
Cheers
Jodie
Can I ask you this Leo?
With the Publish Date it hyperlinks back to the post you are on.
Why is the date linked, what is the purpose of that?
Cheers
Jodie
Hi there,
Author pages are generated by a function so the Old Author Page doesn't really exist unless the function for it is called.
Links on post meta such as the date is just the norm for WordPress.
Thanks very much David.
So due to the author pages generated by a function, I am assuming that Google doesn't index that page. Is that right?
Is there a way to remove the link from the date?
Thanks as always for your continued support.
Cheers
Jodie
I believe so. Author archive isn't very important from my understanding.
Try this snippet for date link:
https://docs.generatepress.com/article/generate_post_date_output/#remove-link-from-date
Thanks very much Leo
That snippet worked.
Cheers
No problem :)