- This topic has 3 replies, 2 voices, and was last updated 1 year, 10 months ago by
Tom.
-
AuthorPosts
-
May 19, 2019 at 5:23 am #904266
Martin U
Hi Tom and wonderful Generatepress team,
I use elements a lot to build custom headers for different pages / post. This works like a charme thank you so much. I do come across one issue
If using the
{{post_author}}
field on a single post header, I get the author name linking to the author archive.I don’t want a link to the author archive, I want simply the author name, no links. That is all.
For the blog index page I have added this to the function php
add_filter( 'generate_post_author_output','tu_no_author_link' ); function tu_no_author_link() { printf( ' <span class="byline">%1$s</span>', sprintf( '<span class="author vcard" itemtype="http://schema.org/Person" itemscope="itemscope" itemprop="author">%1$s <span class="fn n author-name" itemprop="name">%4$s</span></span>', __( 'by','generatepress'), esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ), esc_attr( sprintf( __( 'View all posts by %s', 'generatepress' ), get_the_author() ) ), esc_html( get_the_author() ) ) ); }
This removes the link to the author archive for the blog index page. But I still get the link to the author archive on the single blog pages when using
{{post_author}}
in the custom header.How do I get rid of the of the link to the author archive, I would like to see only the author name without a link to the author archive.
Best
Martin
BTW Is there a place for feature requests/suggestions?
May 19, 2019 at 9:16 am #904573Tom
Lead DeveloperLead DeveloperHi there,
Give this function a try:
add_filter( 'generate_page_hero_post_author', function() { global $post; $author_id = $post->post_author; return sprintf( '<span class="author vcard" itemtype="http://schema.org/Person" itemscope="itemscope" itemprop="author"><span class="author-name" itemprop="name">%s</span></span>', esc_html( get_the_author_meta( 'display_name', $author_id ) ) ); } );
Let me know π
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/
Ongoing Development: https://generatepress.com/ongoing-developmentMay 19, 2019 at 11:10 am #904658Martin U
Worked like a charme, thank you so much, Tom.
May 19, 2019 at 5:01 pm #904840Tom
Lead DeveloperLead DeveloperYou’re welcome π
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/
Ongoing Development: https://generatepress.com/ongoing-development -
AuthorPosts
- You must be logged in to reply to this topic.