How To Remove Author And Date Information From Your WordPress Posts

There are instances where you may want to remove author and date information from your posts. For example, if you’re the sole writer behind your blog and you already have a compelling About Me section, there’s no point in wasting your web space with redundant information.

In another instance, older but still relevant posts can benefit from no published date. Believe it or not, we often judge something subconsciously. A 10-year-old blog post can imply dated content, even if it’s not, thereby warding off visitors.

Therefore, this mini WordPress tutorial will show you step by step how to remove author, date, or any entry meta.

What tools do you need

  • Create a child theme of the theme you’re using, and activate it on your blog. I explained how to do that in this tutorial.
  • Cyberduck, an FTP client that allows you to download a theme file to your computer, modify it, and then reupload to your WordPress site’s server.
  • Install the Show Current Template plugin, which displays which template files are used by each page. Templates are the files that control what to display on each page. More information about template files can be found here.

You may be asking: “Wait, can I do this without creating a child theme?”. I had the same question when I started, and my answer now is: A child theme will make you life much easier. If you edit your parent theme directly, it’s way too easy to mess up and break your site

What you should know beforehand

Generally, I’m assuming that you:

  • are comfortable with using Cyberduck to manage your WordPress files like downloading, modifying, and uploading.
  • have a basic understanding of HTML and CSS. At the time of writing this tutorial, I have only taken HTML Essential Training and CSS 1 courses from Linkedin Learning. Indeed, everything else can be googled as you go.

For this tutorial, I’m using Popper, an awesome minimalist theme by Morten Rand-Hendriksen. If you’re using a different theme, you’ll probably have to modify slightly, but I hope you can get the idea.

How to Remove Author in WordPress–beginning

First, let’s see what we have in the beginning. Above is a page that displays a single post. At the top is a post meta section that outputs the gravatar, the author’s name, the published date and the link to comment. I want to remove my gravatar and my name.

Step 1: Examine the single.php file

As a rule, a single post page uses the single.php file. You can confirm that by looking at the Show Current Template plugin at the very top, which also displays all the other template files used by this page.

Remove Author in WordPress–Examine Templates

In the image above, the plugin shows that I’m on the single.php file of the child theme. Previously, I had duplicated the single.php file from the parent theme and moved it to the child theme’s folder.

Next, in Cyberduck, select the single.php file and press Cmd + K to download the file to your local computer and open it in your default code editor.

You’ll see that the single.php file looks very simple. In addition, the following code tells you that the actual content of the post is not generated here. It’s generated in a file called content-single.php from the folder template-parts.

<?php get_template_part( 'template-parts/content', 'single' ); ?>

Thus, we should go to the template-parts folder of the parent theme, twirl down to open the content-single.php inside it and see what’s going on here.

Step 2: Examine the theme_posted_on function

Remove author from WordPress posts–content-single.php file

To put it simply, the file is creating an article which has a header with a featured image, if the latter exists. And then it has a title, excerpt, and particularly the entry meta popper_posted_on.

So it’s this function, popper_posted_on, that generates the content you see at the top of a blog post, also known as entry meta.

Traditionally, the theme_posted_on function would be found inside the functions.php file of the parent theme. However, in recent years, it’s been common to move all custom functions into a separate file so that the functions.php doesn’t get too large.

In this case, the Popper theme is built from Underscore, a basic starter them. Hence you’ll find those custom functions in the template-tags.php under the inc folder of the parent theme.

At the very top, we have popper_posted_on as a hookable function. A well-coded parent theme has a series of hookable functions that allow a child theme to override them.

And what in the world are hookable functions? These are functions wrapped in conditional statements to check if the functions already exist in a child theme.

In short, the chid theme’s functions.php file is called before the parent theme’s functions.php file. As a result, you can hook a function into a child theme by giving it the same name as the hookable function in the parent theme. Your child theme’s function will run in place of the one in the parent theme.

In other words, if we put the popper_posted_on in our child theme, it will automatically take precedence over the function that the parent theme ships with.

Step 3: Create a new functions.php file for the child theme

In your code editor, create a new file and instantly save it as functions.php.

Afterward, in the template-tags.php of the parent theme, copy the entire popper_posted_on function, all the way down to the first endif, but not including it.

/**
 * Prints HTML with meta information for the current post-date/time and author.
 */
function popper_posted_on() {

	$author_id = get_the_author_meta( 'ID' );

	$time_string = '<time class="entry-date published updated" datetime="%1$s">%2$s</time>';
	if ( get_the_time( 'U' ) !== get_the_modified_time( 'U' ) ) {
		$time_string = '<time class="entry-date published" datetime="%1$s">%2$s</time><time class="updated" datetime="%3$s">%4$s</time>';
	}

	$time_string = sprintf( $time_string,
		esc_attr( get_the_date( 'c' ) ),
		esc_html( get_the_date() ),
		esc_attr( get_the_modified_date( 'c' ) ),
		esc_html( get_the_modified_date() )
	);

	$posted_on = sprintf(
		esc_html_x( 'Published %s', 'post date', 'popper' ),
		'<a href="' . esc_url( get_permalink() ) . '" rel="bookmark">' . $time_string . '</a>'
	);

	$byline = sprintf(
		esc_html_x( 'by %s', 'post author', 'popper' ),
		'<span class="author vcard"><a class="url fn n" href="' . esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ) . '">' . esc_html( get_the_author() ) . '</a></span>'
	);

	// Display author avatar if author has a Gravatar
	if ( validate_gravatar( $author_id ) ) {
		echo '<div class="meta-content has-avatar">';
		echo '<div class="author-avatar">' . get_avatar( $author_id ) . '</div>';
	} else {
		echo '<div class="meta-content">';
	}

	echo '<span class="byline">' . $byline . ' </span><span class="posted-on">' . $posted_on . ' </span>'; // WPCS: XSS OK.
	if ( ! post_password_required() && ( comments_open() || get_comments_number() ) ) {
		echo '<span class="comments-link">';
		comments_popup_link( esc_html__( 'Leave a comment', 'popper' ), esc_html__( '1 Comment', 'popper' ), esc_html__( '% Comments', 'popper' ) );
		echo '</span>';
	}
	echo '</div><!-- .meta-content -->';

}

Please notice that I didn’t copy the statement if ( ! function_exists( ‘popper_posted_on’ ) ) : and the endif.

Paste the above code into the functions.php that we’ve just created. Save the file, and move it to the popper-child folder in Cyberduck.

Refresh the page, and you should see that it remains the same.

Step 4: Understand the functions.php file

You may look at the above code snipper and think: “What the !@#$ is this dog’s dinner?”. True, this is advanced stuff, but let’s scroll down to the Display author avatar section and me explain briefly.

Remove Author in WordPress–Understand Meta Section

The code tells Wordperss to display author’s avatar if the author has a Gravatar. Then we have some conditional statements that output the HTML that displays the avatar image.

Subsequently, we have the second section, which first sets up the byline class, then displays a variable called byline. This is the author’s name.

Next, it displays a span called posted_on with the variable posed_on, and that indicates the publishing date. Finally, it checks to see if there are comments available, and outputs the comment link if available.

Remove author from WordPress–explanation of functions.php

Step 5: Remove author information from a WordPress post

Earlier, I said that we would remove the author information from the post. In the file, however, we would comment out part of code that we don’t want to get executed by WordPress. By doing so, we would be able add the information back anytime we want.

In PHP, a comment stars with */ and ends with /*. To remove author information from the post, simply comment out the byline span class and variable. Next, to hide the author’s avatar, comment out that section while keeping the echo function that outputs of the meta section as it it.

Remove Author from WordPress post–comment out

Here’s the final result.

Remove author from WordPress post–final

Phew, are you still here? If you’ve made it to this final step, congratulation. I’ve realized that the meta section looks a little lonely now, so I’ll show you how to add the post categories to it. Stay tuned.

Leave a Reply

Your email address will not be published. Required fields are marked *