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');
Thank you for this short guide… I tried the automatic method and it works without a problem.
I tried the automatic fix, but it did not work (it resulted in some strange text appearing at the top margin of the website). I have restored the text back to normal, but perhaps I am pasting the text in the wrong place. When I tried it the first time I pasted it at the very top of the text file before any other text. Should I be pasting it somewhere else in the text box? The functions.php box starts with the following text:
<?php
/**
* TwentyTen functions and definitions
*
* Sets up the theme and provides some helper functions. Some helper functions
* are used in the theme as custom template tags. Others are attached to action and
* filter hooks in WordPress to change core functionality.
Thanks
@JRum: Go to the end of the
<?php
line, press Enter to create a new line, and paste in the code. Let me know if that works.Great! Thanks for this helpful advice!
This worked for me too. Thanks! I have got a strange space above my header now, which is strange. I’ll look that up separately. Anyway, thanks again. It was quick and easy to do.
My “appearance” menu doesn’t have an “edit” option. It has themes, widgets, menus, background, header, custom design, iPad, extras, and nothing else. How do I find this mysterious theme editor? (I’m using this theme 2010)
It sounds like your blog is running on a WordPress multisite setup. If you’re using WordPress.com or another multisite network that’s owned by someone else, editing themes won’t be an option. If you’re running your own multisite setup, you’ll have to go to Network Admin to find the theme editor.
What’s “multisite setup?”
I don’t have “editor” in “Appearances.” I’ve tried changing the code and fooling around with no real experience in what I’m doing, but nothing saves. Obviously, MY version is idiot-proofed. : )
This Word Press stuff is a mystery. I don’t understand the different types – the difference between the free version and the templates for purchase. And they don’t really want to tell us…
If they could be clear about what I’m getting, I’d make the choice to upgrade/purchase/buy hosting/whatever/add on all the stuff that costs more money in order to get what I want. But they don’t say what you’re getting until you bought it and it doesn’t meet your expectations.
I’m super cautious now. By the time I’m done throwing down the credit card, I could have had a ‘real’ website for what I spent.
Is it possible to remove date information only from meta description of the page and still show it on the page?
Yes. The date information shows up in the meta description because your theme marks up your posts as hEntry objects. There should be a <div> with the “hentry” class surrounding each post, and another <div> with the “hfeed” class surrounding the post list. I haven’t tested it myself, but as far as I know, removing those classes should remove the date info from your meta descriptions.
I tried it and got this error…
Warning: call_user_func_array() [function.call-user-func-array]: First argument is expected to be a valid callback, ‘__return_false’ was given in /home3/healthcl/public_html/fmg/blog/wp-includes/plugin.php on line 166
What version of WordPress are you using? As stated in the post, the automatic method requires WordPress 3.0 or above.
Great suggestion and works well for me. I have no programming experience and experimented by adding a couple of extra lines of code in there. this allowed me to remove the author and title as well as the date and time.
function jl_remove_post_dates() {
add_filter(‘the_date’, ‘__return_false’);
add_filter(‘the_author’, ‘__return_false’);
add_filter(‘the_title’, ‘__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_author’, ‘__return_false’);
add_filter(‘get_the_title’, ‘__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’);
When publishing content that is time-oriented I use static pages. Nevertheless, information on alternative approaches is always appreciated. I’ll file it away for future use. Thanks.
Hi John, nice site you have. And thanks for helping us out with these handy articles.
I tried to turn of the date for my wp site. I got it fixed with the more “aggressive” version. The one above didn’t work. But I have a (maybe stupid) question: is it possible to turn of the Published | By admin notice on my site?
please have a look: bloemistinamsterdam (dot) nl didn’t put a link, don’t want it to be indexed yet.
Hope you can help!
thanks,
Stefan
hey, @stefan your question is not stupid at all.because i also need this fix and i think everyone will need it because you don’t want to show “published on” since you don’t want the date at all. 🙂
PS:thanks for this function but if can also remove the published on with function then it would be great!
Hello – I desperately want to exclude the date and the words “no comments” from my blog posts because I want them to be static. I tried copying and pasting the automatic fixes but neither one of them worked. I am actually not sure where I should be copying them. I went into appearance then editor on my site and there is a list of templates. I tried pasting the fix in the one labeled template and then in the one labeled blog post template and neither of those worked. Your help would be very much appreciated. Thanks – Phyllis
Hi John,
great post. It helped me a lot.
A little warning to you readers, if you want to modify the default theme it is better to copy it and use this copied version.
Otherwise, WordPress will overwrite your modified default theme during an update.
Thanks
Tried the automatic method and it worked for me, thanks! The text ‘Posted at’ is still there though. Is there any way i can remove it as well
Great Post
Hi John,
I used your automatic method (the aggressive version) to delete dates from my word press blog. Unfortunately I accidentally forgot to copy the last few characters ); of the code and now the entire website/admin-area is not working anymore. Do you have any idea how to fix it? I cannot open the website at all…
Looking forward to hearing from you soon!
Conny
Use an FTP program to rename your theme’s functions.php file.
Hey John
Thanks for great post …
I want to remove dates from certain category ..How can i do that ? :)I just found following line in loop-single.php “sprintf(esc_attr__( ‘View all posts by %s’, ‘unspoken’ ), get_the_author() ), get_the_author()), get_the_date(),”
Lemme know what code i need to add. Would be great help to me 🙂
Baba
The first automatic option worked like a charm. Thanks
How can i check if i did removed the dates from google-serps? It does take some time till google crawls my site. Is there a way to check this immediatedly?
I tried short cut, and succeded thanks.
Thanks John!!
Worked great for me ..
The automatic method worked like charm on my website! Thanks