How to remove the date from WordPress posts

Found it!!

From John Lamansky WordPress Expert site

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”

 

Honestly #1 just looks like too much effort. I prefer the idea of just messing up one file, so I select choice #2 (below)…

 

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

The first (less aggressive) fix worked for me! Thank you John!

I see you haven’t posted anything new on your site since 2011, I hope all is well with you.

Thank you

Share this:

0 comments

  1. Messed Up the Code says:

    Hi!

    I used the first code in your automatic method, but I messed it up. I want to delete the code, but it’s not showing in my Editor. Can you please tell me what to do to delete it? I really appreciate the help.

    • Mike says:

      Select APPEARANCE, THEME then EDITOR.

      On the right side of the page, select the “FUNCTIONS.PHP” file (also called THEME FUNCTIONS)…

      You should be able to see the code you placed there. If not. You didn’t put it there in the first place or it has been over written.

      Perhaps you placed the code on a different file by accident. If you open each file on the right-side and search (CTRL-F) for the line “remove_post_dates”, you will find the code you placed.

      Pleas let me know if this helps.

Leave a Reply

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