Remove Author Information from Twenty Sixteen Theme

Even though the default WordPress theme is highly customizable, there are many things that you cannot change directly. For example, every post will show the author’s name and gravatar next to it on the left-hand side, as shown here:

Author Name Next to Every Blog Post
Author Name Next to Every Blog Post

Solutions on the net for removing this only focus on hiding it using CSS using something like this:

.author {
    display: none;
}

While this solution works, the information is still visible in the page source code. To thoroughly remove author information from Twenty Sixteen, we have to stop it from being generated in the first place. And CSS cannot help us with this. In this tutorial, I will show you how to remove all author-related information from the page, so it’s not visible even in the page source.

Overriding a Core Twenty Sixteen Function

To do this, we must override a core Twenty Sixteen theme function known as twentysixteen_entry_meta(). The original location of this function is in /wp-content/themes/twentysixteen/inc/template-tags.php:

Function in Template tags.php
Function in Template tags.php

Looking at the source code, we can create our own modified function without the parts that generate the author’s information. You can view the source code of the twentysixteen_entry_meta() function on Github. Here’s what we need to paste into our functions.php file:

function twentysixteen_entry_meta() {

	if ( in_array( get_post_type(), array( 'post', 'attachment' ) ) ) {
		twentysixteen_entry_date();
	}
	$format = get_post_format();
	if ( current_theme_supports( 'post-formats', $format ) ) {
		printf( '<span class="entry-format">%1$s<a href="%2$s">%3$s</a></span>',
			sprintf( '<span class="screen-reader-text">%s </span>', _x( 'Format', 'Used before post format.', 'twentysixteen' ) ),
			esc_url( get_post_format_link( $format ) ),
			get_post_format_string( $format )
		);
	}
	if ( 'post' === get_post_type() ) {
		twentysixteen_entry_taxonomies();
	}
	if ( ! is_singular() && ! post_password_required() && ( comments_open() || get_comments_number() ) ) {
		echo '<span class="comments-link">';
		comments_popup_link( sprintf( __( 'Leave a comment<span class="screen-reader-text"> on %s</span>', 'twentysixteen' ), get_the_title() ) );
		echo '</span>';
	}
}

Note that you cannot place this code in a custom plugin! Typically, I recommend pasting PHP code into a custom plugin instead of functions.php. But if you try and paste the above snippet into a plugin, you’ll get a fatal error saying that you cannot redeclare it because it’s already declared.

Cannot Redeclare
Cannot Redeclare

This will only work when pasted into Twenty Sixteen’s functions.php file. You can learn how to do that from my earlier tutorial on pasting code snippets into WordPress. Of course, it’s equally vital for you to create a child theme of Twenty Sixteen and modify the child’s functions.php instead of the original. This is because your changes will get overridden whenever the WordPress team releases a newer version of the theme.

So after you’ve created a child theme and pasted the above code into the child’s functions.php, you should see that the author information has vanished, as shown here:

Remove Author Information from Twenty Sixteen
Remove Author Information from Twenty Sixteen

You can see that this information has vanished from the visible page and the source. This is important if your goal is to post without anyone noticing the author’s name for whatever reason. A simple CSS fix might be easy, but it doesn’t solve the main problem. Only overriding the primary function itself will remove author information from Twenty Sixteen.

About Bhagwad Park

I've been writing about web hosting and WordPress tutorials since 2008. I also create tutorials on Linux server administration, and have a ton of experience with web hosting products. Contact me via e-mail!

Comments

  1. Thanks for sharing this. I have tried in putting this code my child’s php but it the author info is still there. Not sure what I did wrong. Also in my back-end if see this ‘%3$s’ above my site screen. Think something is not right
    Hope you can help me out.
    Many thanks,
    Hazy

    Reply

    • WPTweaks Admin says

      It’s going to be tough to debug from here. You can introduce some “echo” statements into parts of the function to see if the code is being executed or not. Make sure your child theme is activated, and you’ve inserted the code into functions.php of your child them etc etc.

      It should work if all goes well…

      Reply

      • Not sure what ‘echo’ statements are and how I should use it. The child theme is activitated that’s for sure and I did put into fuction.php of the child.
        I got the below error:
        Error 400

        website.nl
        Thu Nov 24 09:27:12 2016
        Apache

        And the content of my php is as follows:

        get(‘Version’)
        );
        }
        add_action( ‘wp_enqueue_scripts’, ‘my_theme_enqueue_styles’ );
        ?>

        /* remove meta dat */

        function twentysixteen_entry_meta() {

        if ( in_array( get_post_type(), array( ‘post’, ‘attachment’ ) ) ) {
        twentysixteen_entry_date();
        }
        $format = get_post_format();
        if ( current_theme_supports( ‘post-formats’, $format ) ) {
        printf( ‘%1$s%3$s’,
        sprintf( ‘%s ‘, _x( ‘Format’, ‘Used before post format.’, ‘twentysixteen’ ) ),
        esc_url( get_post_format_link( $format ) ),
        get_post_format_string( $format )
        );
        }
        if ( ‘post’ === get_post_type() ) {
        twentysixteen_entry_taxonomies();
        }
        if ( ! is_singular() && ! post_password_required() && ( comments_open() || get_comments_number() ) ) {
        echo ”;
        comments_popup_link( sprintf( __( ‘Leave a comment on %s’, ‘twentysixteen’ ), get_the_title() ) );
        echo ”;
        }
        }

        Hope you can help.

        Thanks,
        Hazy

        Reply

        • WPTweaks Admin says

          Ah, I see. Could you make sure that your file starts with the tag:

          Try it out and let me know if it works!

          Reply

          • I have below code in my child php. But stil error . I got this : %3$s. Above my site. This is part of your code. Maybe something is wrong or broke in your coding

            get(‘Version’)
            );
            }
            add_action( ‘wp_enqueue_scripts’, ‘my_theme_enqueue_styles’ );
            ?>

            function twentysixteen_entry_meta() {

            if ( in_array( get_post_type(), array( ‘post’, ‘attachment’ ) ) ) {
            twentysixteen_entry_date();
            }
            $format = get_post_format();
            if ( current_theme_supports( ‘post-formats’, $format ) ) {
            printf( ‘%1$s%3$s’,
            sprintf( ‘%s ‘, _x( ‘Format’, ‘Used before post format.’, ‘twentysixteen’ ) ),
            esc_url( get_post_format_link( $format ) ),
            get_post_format_string( $format )
            );
            }
            if ( ‘post’ === get_post_type() ) {
            twentysixteen_entry_taxonomies();
            }
            if ( ! is_singular() && ! post_password_required() && ( comments_open() || get_comments_number() ) ) {
            echo ”;
            comments_popup_link( sprintf( __( ‘Leave a comment on %s’, ‘twentysixteen’ ), get_the_title() ) );
            echo ”;
            }
            }

            Reply

          • WPTweaks Admin says

            I see you still have the initial part starting with get(‘Version’) and ending with ?> . That’s not part of the code snippet. Can you replace that entire block with <?php as suggested earlier, and let me know the results?

            Reply

          • This is strange. I did have my codes started with <?php ….. . I thought I didnt copy the codes correct to your reply box the first time. But this time I double checked whether I copied all the codes from my php and I did. So parts of the codes got removed after I send reply. It might be easier if I mail it directly to your email address instead of through this reply box.

            Reply

  2. Can you please tell me how to do it for
    CPMAGZ – A Magazine Theme By Code Themes.

    Reply

  3. Brilliant. Shame on wordpress for making things so hard!

    Now, what it we want to get rid of that whole section and make the body of the text the same width as the featured image? If this were just HTML it would be a piece of cake but the insanity of this php is impossible!

    Reply

  4. Guillaume says

    Hi,

    Thank you for this tip. I’ve tried removing only the author name, but keeping the avatar. It works on large screen versions, using a child theme for Twenty-Sixteen, but it messes up the mobile version, where posts’ meta data are separated with slashes. See this support thread:
    https://wordpress.org/support/topic/remove-author-name-but-keep-avatar-publish-date-and-categories/
    Thank you for any pointer on how to solve this.

    Reply

Speak Your Mind

*

WP-Tweaks