If your content is not time-oriented (such as when using WordPress in non-blog contexts), you may wish to remove the publication date from your posts since this information is not relevant and can give the impression that your older content is outdated.
1. The Manual Method
The “proper” way to do this would be to edit your theme and remove the code that displays the post dates.
- Backup your theme, just in case
- Go to “Appearance > Editor” and repeat the following steps for each of your theme’s PHP files
- Look for these function calls in your theme’s code:
the_date()
,echo get_the_date()
,the_modified_date()
, andthe_time()
- Surround the function calls with PHP comment markers (
/*
and*/
); here are some examples:<?php /*the_date();*/ ?> <?php /*the_date('F j, Y');*/ ?> <?php /*echo get_the_date();*/ ?> <?php /*the_modified_date();*/ ?> <?php /*the_modified_date('', 'Last modified ');*/ ?> <?php /*the_time( get_option('date_format') );*/ ?>
- You may want to remove other text surrounding the function call. For example, if your theme has this code…
<div>Published on <?php the_time( get_option('date_format') ); ?></div>
…and you replace it with this…
<div>Published on <?php /*the_time( get_option('date_format') );*/ ?></div>
…your theme will output “Published on,” but not the date. Deleting “Published on” from your theme file will remove it from your site. Just be aware that you may have to remove text like this from your theme files to get a clean-looking result.
- Click “Update File”
2. The Automatic Method
If you’re looking for a quick fix, just go to “Appearance > Editor” in your WordPress admin and add this code to your theme’s functions.php file. Put it at the top of the file, but after the opening <?php
line.
function jl_remove_post_dates() { add_filter('the_date', '__return_false'); add_filter('the_time', '__return_false'); add_filter('the_modified_date', '__return_false'); } add_action('loop_start', 'jl_remove_post_dates');
(Note: This method requires WordPress 3.0 or above)
Now check your site and verify that the post dates are gone. If they’re not, try replacing the code above with this more “aggressive” version:
function jl_remove_post_dates() { add_filter('the_date', '__return_false'); add_filter('the_time', '__return_false'); add_filter('the_modified_date', '__return_false'); add_filter('get_the_date', '__return_false'); add_filter('get_the_time', '__return_false'); add_filter('get_the_modified_date', '__return_false'); } add_action('loop_start', 'jl_remove_post_dates');
Hi, Thanks so much for your informative article. However, I will like to know will there be any side-effects after removing the post dates? Is this a blackhat method?
John,
You’re the man! I used the “aggressive” code and it worked a treat. Site bookmarked and instead of trawling through Google and WordPress for umpteen different ways of doing something. I’ll be back here to search for my solutions.
I like simple and effective solutions, not long winded ones!
Thanks so much and have a great day!
Jonny
Booyaah!! That’s what I’m talking about! After going through about a dozen and a half websites, I finally found a solution that worked. Thanks a billions Mr.Lamansky, you rock!
Thank you, the more aggressive code worked for my site
Hi john – sorry to be such a latecomer to the party…
Is this date/time removing option just a feature of the premium/business upgrade versions of wordpress? It may be that I’m just so techno useless, but I can’t find any options of ‘appearance>editor’ or function.php files on my admin page. 🙁
Heather
Hey John,
Thanks so much for this, the automatic option worked a treat for me. Do you know how I can also remove the Author name?
Cheers
Suz
Hello John,
I am using the metro pro theme and I went to try the automatic methods but neither worked. I then tried the manual method but I did not see any of the function calls (the_date(), echo get_the_date(), the_modified_date(), and the_time()) in the code. Any suggestions?
Thank you,
Jake
Thanks for the awesome solution.
I was able to remove date, time, category with the code.
But I am unable to remove the “By Posted at”. I have commented out these in every php file as you instructed but no success.
I am eagerly waiting for your reply. Please help me out.
Hi there!
first of all thank you for such great tut
secondly, I wonder after set up function.php is show an errors on google test structured data “missing author” and “missing updated”?
Hi John,
Its worked for me, i have an issue i have removed author from posts now i removed date & time from this code but it shows “/by” on posts.
How to remove that ? please help.
Surprisingly easy, even for a 3month old “wordpressor”.
Much appreciated
The aggressive worked, I suppose updating it will have to be redone,
Thanks very much John
Cheers,
Lou
Thanks for this John, I always feel like some of the code wordpress provides often ends up bloating the content and it isn’t that necessary from a content perspective. Nice to know that you can remove it though.
My problem is somewhat like Cee’s. I used the aggressive code and now my site is down. I got an error notice at first, so I went back and removed the code and saved it. That didn’t help and now my site is completely down. I can’t open the site or get back on as the administrator. If you know how to correct this situation, I’d appreciate it immensely.
Hi Joe. So sorry you ran into trouble. Use an FTP program or the file manager of your web host’s control panel to navigate to the
/wp-content/themes/
folder of your site and rename the folder that contains your theme. That should cause your site to switch back to the default WordPress theme, which should let you get back into the admin.hi how do i remove ‘posted by’ and ‘categories’. i am using deviant elegant theme. any help will be greatly appreciated
First one is not working in MH Themes, second one is working fine. Thanks
Thank you, thank you, thank you!!! I have been trying to figure out how to do this FOREVER! I had to use the more aggressive code, but then it perfectly. Awesome. Thanks so much for sharing your knowledge. I am tech delayed 🙂
It worked very well for me.
Thanks for the help.
Than u so much John. The aggressive option worked on my theme.
That’s great thanks. I had to use the “more aggressive” code but that worked perfectly.
Thanks for sharing.