Tutorials

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

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

How to Find and Fix 404 Errors

If you’ve changed post slugs, taxonomy slugs, or permalink structures, you likely created 404 pages (page-not-found URLs) along the way.

These 404 pages certainly aren’t helpful for visitors who stumble across them and can increase your bounce rate. It can be a particular problem if search engines, pingbacks, and/or internal and external links are sending traffic to the old URLs.

Here’s how to resolve the issue:

Continue reading

How to Backup Your WordPress Theme

If you’re about to make a modification to your theme files that you aren’t sure about, it’s a good idea to backup your theme, especially if your theme is custom-made (i.e. you can’t just re-download it if something goes wrong), or if you have many other theme modifications you want to preserve.

Here are two ways to do it:

Continue reading

How to Put Blog Posts in Their Own Subdirectory

Cool WordPress-as-a-CMS tip: If your WordPress-powered site includes a blog as a component, rather than the main function, you can opt to put blog posts and archives (category/tag/date/author) into their own subdirectory (such as “blog”).

Continue reading