- This topic has 24 replies, 4 voices, and was last updated 3 years, 2 months ago by
David.
-
AuthorPosts
-
February 9, 2023 at 9:28 am #2527530
Dave
Hi There,
Currently every post I publish has a byline, which links to the standard WordPress author page.
For one author in particular (me), I’d like to change this so instead of linking here:
https://www.irreverentgent.com/author/dave-bowden/
The byline would link here:
https://www.irreverentgent.com/about-dave-bowden/
I could add a 301 redirect, but I’d prefer to do it without adding a redirect, if possible.
February 9, 2023 at 11:17 am #2527649Ying
StaffCustomer SupportHi Dave,
Can I see your site to check the structure?
February 9, 2023 at 11:18 am #2527650Dave
Hi Ying,
Sure, what do you need from me in order to do that?
February 9, 2023 at 11:58 am #2527678Ying
StaffCustomer SupportOh you just need to link me to a page or post where I can see the author’s byline 🙂
February 9, 2023 at 12:18 pm #2527688Dave
Oh sorry, here you go: https://www.irreverentgent.com/best-dr-squatch-soap-scents/
February 9, 2023 at 12:54 pm #2527704Ying
StaffCustomer SupportTry this PHP code, just need to replace the
1inget_the_author_meta( 'ID' ) == 1with your actual user ID.add_filter( 'generate_post_author_output', function() { $byline = '<span class="byline">%1$s<span class="author%8$s" %5$s><a class="url fn n" href="%2$s" title="%3$s" rel="author"%6$s><span class="author-name"%7$s>%4$s</span></a></span></span> '; $schema_type = generate_get_schema_type(); if ( get_the_author_meta( 'ID' ) == 1 ) { printf( $byline, apply_filters( 'generate_inside_post_meta_item_output', '', 'author' ), 'https://www.irreverentgent.com/about-dave-bowden/', /* 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' ), 'microdata' === $schema_type ? ' itemprop="url"' : '', 'microdata' === $schema_type ? ' itemprop="name"' : '', generate_is_using_hatom() ? ' vcard' : '' ); } else printf( $byline, 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' ), 'microdata' === $schema_type ? ' itemprop="url"' : '', 'microdata' === $schema_type ? ' itemprop="name"' : '', generate_is_using_hatom() ? ' vcard' : '' ); });February 9, 2023 at 1:24 pm #2527734Dave
Where do I add it? I tried adding it to both the functions.php and the content.php files but it didn’t seem to work.
February 9, 2023 at 1:50 pm #2527761Ying
StaffCustomer SupportYou can add the PHP code to the
functions.phpof your child theme, or to a plugin like code snippet.February 9, 2023 at 1:57 pm #2527766Scott
Nice. I’m going to try this too.
February 9, 2023 at 2:02 pm #2527770Ying
StaffCustomer SupportHi Scott,
Let me know if it works 🙂
February 9, 2023 at 2:40 pm #2527791Dave
I added it to code snippet, but no luck, unfortunately!
February 9, 2023 at 2:48 pm #2527792Ying
StaffCustomer SupportCan you show me the exact code you are using? please wrap the code with the code tag so it keeps format 🙂
February 9, 2023 at 2:50 pm #2527793Dave
I just copied what you gave me, and changed the ID number:
add_filter( 'generate_post_author_output', function() { $byline = '<span class="byline">%1$s<span class="author%8$s" %5$s><a class="url fn n" href="%2$s" title="%3$s" rel="author"%6$s><span class="author-name"%7$s>%4$s</span></a></span></span> '; $schema_type = generate_get_schema_type(); if ( get_the_author_meta( 'ID' ) == 2 ) { printf( $byline, apply_filters( 'generate_inside_post_meta_item_output', '', 'author' ), 'https://www.irreverentgent.com/about-dave-bowden/', /* 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' ), 'microdata' === $schema_type ? ' itemprop="url"' : '', 'microdata' === $schema_type ? ' itemprop="name"' : '', generate_is_using_hatom() ? ' vcard' : '' ); } else printf( $byline, 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' ), 'microdata' === $schema_type ? ' itemprop="url"' : '', 'microdata' === $schema_type ? ' itemprop="name"' : '', generate_is_using_hatom() ? ' vcard' : '' ); });February 9, 2023 at 3:03 pm #2527800Scott
Does that author actually have content published? I was experimenting with an unrelated author page issue recently and nothing showed until content was actually published. Once published content from that author was there it worked.
Just a guess …
February 9, 2023 at 3:46 pm #2527830Ying
StaffCustomer SupportHave you already used a custom function to change the author byline, if so, the new function might not work?
And make sure the cache is cleared.
-
AuthorPosts
- You must be logged in to reply to this topic.