Remove URL from author name in GeneratePress

If you are using the GeneratePress theme; below the post title with the published date you will see Author’s name. And the author name is clickable by default. If you click the author name you’re redirected to a list of posts published by the very author.

Having a clickable author name can be wonderful for some; while some detest the idea of a clickable author name.

So, today in this post we’ll learn a quick and easy way to remove the author name hyperlink in the GeneratePress theme.

For this tutorial we will be using a plugin called WPCode. If you want to know the process of installing a plugin, you can check our detailed guide on installing a WordPress plugin.

After installing the WPCode plugin, from your WordPress dashboard:

  • Go to Code Snippets >> + Add Snippet >> Add your Custom Code
Adding code snippets via WPCode.
Adding code snippets via WPCode.
  • Give a title that is easy to remember. For example: Author name hyperlink removal
  • Change the Code type to “PHP Snippet”
Adding code snippets via WPCode to remove hyperlink from author name in GeneratePress theme.
Adding code snippets via WPCode to remove hyperlink from author name in GeneratePress theme.
  • Paste the below code
  • Change the status to activate and then Save the snippet
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() )
		)
	);
}

Bingo. Now you will have the hyperlink removed from the author name.

Read More WP Tutorials from GeneratePress theme

How to show last updated date on GeneratePress theme
How to remove URL field in GeneratePress comment form
How to add breadcrumbs in GeneratePress theme using SEO plugins
How to remove background colour of top widget sidebar in GenereatePress

Leave a Comment