WordPress bylines are the little snippets of text that appear above each post. It’s usually different for each theme, and each site. Sometimes it includes the author name, sometimes, the last modified date, or published date. Whether or not it’s a good thing to include the byline is a subject of much debate. I think with the latest Google’s “medic” SEO update, it’s important to identify your authors to establish expertise, authority, and trust.
But if you want to get rid of the byline in WordPress, here’s how to do it.
Method 1 (Easy): Use CSS
Since each theme generates its byline differently, it’s easier to simply hide the byline with CSS. This has its own disadvantages as explained below, but here’s how to go about it.
First, we need to get the class of the byline used. To do this, right-click the byline and select “Inspect Element” in Google Chrome, or the equivalent menu item in other browsers. Now go line by line and find the highest element that contains the byline, and nothing else, like this:
You can see here, that the class “post-meta” encloses the byline with the date. If I go any higher, it encompasses the title as well, and I don’t want to hide the title!
Now using the class information, I can easily construct a CSS rule to hide the byline like this:
.post-meta { display:none; }
As you can see below, we can enter CSS into the theme customizer in WordPress and test out the results before applying the rules:
The byline has vanished. That was easy!
Disadvantages of Hiding the Byline via CSS
Remember that hiding something via CSS isn’t the same as removing it from the web page. Someone can still easily view the source page of the site and see what’s in there. So if your goal is to hide the author name from people as a security matter, this is a terrible solution.
To change the HTML itself, we’re going to have to modify the PHP code. Here’s how to do that.
Method 2 (Comprehensive): Change the Theme
The second method is the navigate to the theme files and make changes there directly. However, this isn’t as easy as it used to be. WordPress pages are no longer loaded from a single template like in the old days. These days, everything is mashed together from multiple sources. I’d written an earlier tutorial to show how to which template pages are used for any given WordPress post.
For our purposes however, we can make use of an even more direct method. First, download and install the plugin called “String Locator”. This will allow us to find out exactly which theme files we need to modify to remove the byline. For example, after installation, go to “Tools -> String Locator”, and type in the name of the byline class like this:
On this page, you can see that the class “post-meta” is referenced in two different files. If you want to remove the post meta byline on single pages, then we need to modify “content-single.php”. Clicking the search result will take you directly to the place it’s mentioned.
Here, you can modify the PHP code to remove the byline entirely. Or you could write your own function. You can see that the byline is generated via the function “write_header_meta”. If you want, you can use the string locator plugin to find out where that function is defined, and then modify the function itself so that it returns something else.
How you want to go about it is up to you. I would just suggest that you use a child theme, and backup your files and database before you make any changes!
I’m a NameHero team member, and an expert on WordPress and web hosting. I’ve been in this industry since 2008. I’ve also developed apps on Android and have written extensive tutorials on managing Linux servers. You can contact me on my website WP-Tweaks.com!
Leave a Reply