How to Remove Dates from WordPress Posts
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.
- 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');