Removing Posted At & Posted By From Your WordPress Theme

I recently decided to remove the “Posted By James” at the top of every blog post. This is my personal blog after all, who else would have posted to it? I also decided that I would prefer people reading my blog posts not to be too concerned when I wrote each post. After all each one of my posts is a timeless classic right? Right?!

Anyway to remove the “Posted By Author, Posted On Date” from the post summary (the snippets of a post that are usually seen on the front page index and search page) you will need to edit two of the template’s files, which is made surprisingly easy by WordPress.

Before you edit a theme it is recommended that you first make a child theme. This allows you to make customisation without having to worry about automatic theme updates clobbering your changes.

Now that you have a child theme set-up, log into your WordPress admin tools. Click the “Appearance” menu item, then click the “Editor” sub menu item. This opens up the “Edit Themes” page, a neat feature of WordPress that allows you to edit the source code of installed themes.

By default the theme that WordPress is currently using will be selected ready for editing. If you want to edit a different theme then select it from the drop down in the upper right of the screen and hit the select button.

Ok, I should note that this information is based on one of the default WordPress themes “Twenty Eleven” that comes with WordPress 3.x, but the advice will hold for many themes.

Now that we have our theme selected, you will see all the files that make up the theme listed on the right hand side of the page. To edit a file simply click the link for the file and the editor will load up that file.

The two files that need to be edited are (Twenty Eleven) content-single.php and content.php. Near the top of each file you need to find the following bit of code:

<div class="entry-meta">
  <?php twentyeleven_posted_on(); ?>
</div><!-- .entry-meta -->

We need to stop the <?php twentyeleven_posted_on(); ?> from being inserted into the pages. There is a number of ways to acheive this including simply deleting the code. I personally don’t like the permanence that deletion brings (we might change our minds!), so I recommend using html comments to comment out the bit of php.

So what you should have at the end is something like:

<div class="entry-meta">
  <!--?php twentyeleven_posted_on(); ?-->
</div><!-- .entry-meta -->

Note the “!–” at the beginning of the tag and the “” at the end. This stops the code inside from being executed and included in the html of our pages. Once you have made the change, click the “update file” button and rinse and repeat for the second file.

Now, when your pages are displayed you shouldn’t see “Posted By X on Y” at the top of each post, or on the index page and your posts are ready1 to become the timeless classics they deserve to be.



[1] If you are using page caching (you are aren’t you?) then remember to clear out your cache so that the changes will take effect.