If you maintain a WordPress website whose contents are not time oriented, for instance in a non-blog context, you may want to give the dates. Publication dates might give the impression that your content is old and outdated. There are many ways you can use to remove the publication or modified dates from your WordPress website. Here we are going to highlight the simplest and quickest ways to achieve that without having code knowledge or straining that much.
1. Plugins
There are many plugins available in the WordPress repository that remove dates from posts. For many, this is an easy way out. However, some people may not want to use more plugins on their WordPress website.
2. CSS
Copy the code below and paste it in the Additional CSS section.
- Navigate to WP Admin > Appearance > Customize.
- Then proceed to “Additional CSS” section.
.entry-meta {
display: none;
}
Or you can try the code below.
.entry-meta .entry-date.published {
display: none;
}
3. Theme file editor
This method is only suggested to those who are well versed in editing WordPress files.
a. Functions file
Before using this method, ensure that you maintain a complete documentation and backup of your WordPress website.
- Navigate to WP Admin > Appearance > Theme File Editor.
- Select functions.php.
- Insert the following code at the last line in the functions.php.
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');
If the above code doesn’t work, try replacing it with the one below which is more “aggressive”.
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');
b. Removing content file codes
This method is tedious and can end up damaging your theme. So, before you proceed ensure you back up your theme first.
- Navigate to WP Admin > Appearance > Theme File Editor.
- Choose the template file inside the template-parts folder.
- Select the content.php first and remove the code section of the date.
c. Editing function calls codes
This method is tedious and can end up damaging your theme. So, before you proceed ensure you back up your theme first.
- Navigate to WP Admin > Appearance > Theme File Editor.
- Look for function calls in your theme’s code: the_date(), echo get_the_date(), the_modified_date(), and the_time(). Like the ones shown below:
<?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') ); ?>
<div>Published on <?php the_time( get_option('date_format') ); ?></div>
Surround the function calls with php comment markers (/* and */); as shown below.
<?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') );*/ ?>
<div>Published on <?php /*the_time( get_option('date_format') );*/ ?></div>
Your theme may leave “Published on” output. You can proceed to delete “Published on” from the content.php file of your theme.