How to Remove Dates from WordPress Posts

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.

  1. Backup your theme, just in case
  2. Go to “Appearance > Editor” and repeat the following steps for each of your theme’s PHP files
  3. Look for these function calls in your theme’s code: the_date(), echo get_the_date(), the_modified_date(), and the_time()
  4. 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') );*/ ?>
  5. 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.

  6. 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 the top of your theme’s functions.php file:

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');

14 Comments

  1. SAC

    Thank you for this short guide… I tried the automatic method and it works without a problem.

  2. JRum

    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

  3. Grace Qi

    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.

  4. 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.

  5. Jackie

    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

  6. Sean Armstrong

    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’);

  7. 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.

  8. stefan

    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

  9. Mahesh

    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!

  10. IH

    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

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>