How to remove URL from Author Name in GeneratePress Theme?
In this tutorial, we are going to learn to remove URL from Author Name in Generatepress Theme. By default, there is a link in Author Name in every WordPress theme. When you hover over the author’s name you can see the link.
The link reveals the WordPress username. so the best solution for this is to hide or remove the URL/link from the Author Name.
As I am using GeneratePress Premium Theme. There are many ways to insert a code in GeneratePress but here we are using a plugin Method.
Here, we are going to use the Code Snippets plugin. It is one of the best plugins to insert PHP Snippets in functions.php.
Every time you use the theme’s functions.php, you may mess up with the original theme codes.
so for that, you don’t have to create a child theme as Code Snippets plugin provides the extended functionality to insert PHP code in WordPress sites.
Alternative Method: You can create a GeneratePress Child Theme and you can use functions.php to insert the following code.
The best thing about a GeneratePress child theme is that you don’t have to create yourself. Tom Usborne, the found and lead developer of GeneratePress has created a child theme for you.
Also Read: Display Related Posts in GeneratePress Theme
Remove URL from Author Name in GeneratePress Theme
Follow the simple step to Remove link from Author Name in GeneratePress Theme.
- Go to
Plugins > Add New > Install Code Snippets
- Activate the
Code Snippets
Plugin. - Go to
Code Snippets > Add New
- Add the Following Code.
- Activate it.
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="" 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() ) ) ); }
Bottom line is:
I hope this Remove URL from Author’s Name code will help you to get the desired result.
If you have any feedback/comments, please feel to comment or contact us.