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

WordPress Tweaks 2.0 Released!

I recently rewrote my WordPress Tweaks plugin and have launched the new edition as version 2.0. The previous version of WordPress Tweaks (version 1.8) was released 3 years ago (back when WordPress was at version 2.5), so the plugin was definitely in need of an upgrade!

Version 2.0 adds 5 new tweaks, removes 13 outdated tweaks, fixes a few tweaks that broke between WordPress 2.5 and 3.1, adheres to new plugin development best practices that have emerged since WP 2.5, adds an instant search bar, and ups the minimum WordPress requirement from 2.1 to 3.1 (quite the jump!).

For those who aren’t familiar with the plugin, WordPress Tweaks gathers a plethora of assorted options into a convenient list of checkboxes and dropdowns. (WordPress Tweaks is in the same vein as Microsoft’s abandoned TweakUI program, for those who remember it.)

Here’s the current list of supported tweaks:

  • Admin
    • Automatically scroll to the post editor
    • Disable the admin bar
    • Disable the Dashboard
    • Disable the “Search Engines Blocked” notice
    • Disable tag autocomplete
    • Disable WordPress’s admin footer text/links
  • Comments and Pings
    • Disable self-pinging
    • Dofollow comment author links
    • Dofollow comment body links
    • Open external comment links in new windows
  • Media
    • Disable the Flash uploader
    • Default media inserter tab
      • From Computer
      • From URL
      • Gallery
      • Media Library
    • JPEG Quality
  • Posts
    • Disable post revisions
    • Force excerpts on archives
    • Open external post links in new windows
    • Add a “Continue reading” link to excerpts

Install Now

Ready to start tweaking? Just enter the homepage URL of your WordPress site:

How to Fix Missing Post Dates in Your WordPress Theme

The problem:
When you have multiple posts published on the same day, the post date only shows up for the first one when you view the posts on your site.

The fix:

  1. Go to “Appearance > Editor” and repeat the following steps for each of your theme files
  2. Look for instances of this code:
    <?php the_date(); ?>
  3. Replace that code with this code:
    <?php echo get_the_date(); ?>
  4. Click “Update File”

The explanation:
Most WordPress template tag functions that start with “the_” will merely output the values returned by their equivalent “get_the_” functions. However, “the_date()” is an exception to this standard because it adds functionality that’s not present in “get_the_date()”, namely, not outputting the same date more than once per page, which can be a feature or an annoyance depending on your desired functionality.

New URL and Site Design

My “WordPress Expert” blog recently got a redesign and has moved from wordpress.jdwebdev.com to johnlamansky.com/wordpress, joining my technology how-to blog which is now located at johnlamansky.com/tech. I decided it would be nice to consolidate my blogs under one domain name, plus the “jdwebdev” domain didn’t make much sense anymore since I’m no longer seeking out new web development clients.

For you RSS subscribers out there, the RSS URL will remain the same for now, and if I do change it, I’ll be sure to 301-redirect it so you don’t have to update it manually.

The new design isn’t anything too fancy since I’m definitely more a developer than a designer, but if you have any comments I’d be interested to hear them. It’s my first time developing a WordPress theme from scratch instead of basing it off another theme (e.g. Sandbox).

Tip for Plugin Developers: Inline Changelogs

Recently, the Dev4Press and Weblog Tools Collection blogs made posts about integrating plugin changelogs into the Plugins dashboard. This functionality was something I was already doing in the SEO Ultimate plugin, so I thought I’d share my technique for doing this. (My method is different because it’s simpler and it integrates directly into WordPress’s update message.)

Here’s what an inline changelog looks like when implemented:

Example of inline changelog from SEO Ultimate

As you can see, a small notice like this helps users know at-a-glance what’s new in your plugin update.

Here’s the code you can incorporate into your plugin:

Continue reading