-
WeDreamofTravel
Hi,
I followed some of the Generate Press videos on YouTube to create a post meta element and an author byline element. However, the one thing I can’t figure out is how to link the author name to our about page.
We just have two authors at the moment, both of which I’ve added our about page to the website field of the user. I’ve then selected dynamic link “author meta” and the field name as “website”. I thought this would work but I’m clearly doing something wrong!
I’d appreciate any guidance on how to resolve this. For now I’ve added a manual link into the author byline at the end of the post. But I’d love to be able to get the author name to link out from the post meta. Here is a link to one of our posts for reference:
https://www.wedreamoftravel.com/famous-london-landmarks/Thank you!
-
Fernando
Hi there,
To clarify, so both(all) author names should link to your site’s about us page?
For reference, can you share the link to your site’s about us page? The link on your menu is currently not working.
-
WeDreamofTravel
Hi Fernando,
Yes both author names should link to the about page.
Here is the link for the about page:
https://www.wedreamoftravel.com/about/ -
Hi there,
add this PHP Snippet to your site:
function custom_author_link($link, $author_id, $author_nicename) { // set the ID of the static page $page_id = '87'; if ( get_permalink($page_id) ) { $link = esc_url( get_permalink($page_id) ); } return $link; } add_filter('author_link', 'custom_author_link', 10, 3); add_filter('get_author_posts_url', 'custom_author_link', 10, 3);
here:
$page_id = '87';
you will need to change87
to the ID of the about page.
Which you can find by editing the about page, and checking the browser URL fieldAdding PHP: https://docs.generatepress.com/article/adding-php/
What the snippet should do is, anywhere there is a WP generated link for the author archives, it will replace it with the URL to your about page.
-
WeDreamofTravel
Hi David,
Thank you for this. I will give it a go.
Out of curiosity, is the dynamic link option not supposed to link to the website that’s in the user info? It pulls the social media links this way, it seems strange not to be able to pull the website info this way too?
-
WeDreamofTravel
Also I tried adding this code to Code Snippets as a new snippet, but it just appeared as text across the top of our site? Any idea what I’m doing wrong? Thank you!
-
Hi there,
Try pulling the user website via the headline block’s dynamic setting:
author meta
>user_url
.Let me know if it works!
-
WeDreamofTravel
This worked perfectly. Thank you Ying!
-
WeDreamofTravel
Ok, so the link worked and I thought everything looked great. But when I view it on another page or in Incognito mode, all the formatting is messed up.
When I’m logged in both the byline at the top and bottom show a round image with adequate spacing between items. Additionally, the byline at the bottom is in a colored box and a few other formatting things don’t show up when I’m logged out.
Any ideas? I’ve cleared both my browser cache and the website cache but it’s not fixed it.
-
Hi there,
If you are seeing differently logged in and logged out, then it’s usually a cache issue.
Make sure you clear server-level cache as well and try disable all your cache plugins.
Let me know if this helps!
- You must be logged in to reply to this topic.