How do I remove the date from posts?

Ranko Jones

BANNED
Joined
Mar 3, 2011
Messages
1,677
Reaction score
144
I tried the plugin but like alot of ppl it seems it just flat out didn't work.

I've been reading about remove the
Code:
<?php the_date(); ?> or this:
 
  Code:
 <?php the_time(); ?>

but when I look in single.php or whatever else they say I don't see those lines...

What else can I try?
 
Can you post your single.php here? If it does display the post date of course.
 
That is exactly what I was saying it doesn't display it, hence why I wrote a post about it :D.

Here it is anyway:

Code:
<?php
/**
 * @package WordPress
 * @subpackage JohnLoan
 */

get_header(); ?>

        <div id="primary">
            <div id="content" role="main">

            <?php if ( have_posts() ) while ( have_posts() ) : the_post(); ?>

                <?php johnloan_content_nav( 'nav-above' ); ?>

                <?php get_template_part( 'content', 'single' ); ?>

                <?php johnloan_content_nav( 'nav-below' ); ?>

                <?php comments_template( '', true ); ?>

            <?php endwhile; // end of the loop. ?>

            </div><!-- #content -->

            <?php get_sidebar(); ?>
        </div><!-- #primary -->

<?php get_footer(); ?>
 
According to this line:

Code:
<?php get_template_part( 'content', 'single' ); ?>
You need to open content.php and find the date output there. Usually it's somewhere in the printf() function, e.g. something like this:

Code:
<time class="entry-date" datetime="%2$s" pubdate>%3$s</time>
Simple remove it.
 
According to this line:

Code:
<?php get_template_part( 'content', 'single' ); ?>
You need to open content.php and find the date output there. Usually it's somewhere in the printf() function, e.g. something like this:

Code:
<time class="entry-date" datetime="%2$s" pubdate>%3$s</time>
Simple remove it.

Ok, that's solved half of it. The date no long comes up on the front page however it is still showing in individual posts...

Also it still says 'posted on by X'

I would either like to get rid of the 'on' so it just says 'posted by X' or get rid of it all. Probably the 1st one as it still leaves a bit of the personal touch with the penname there.

Or perhaps ideally simply 'by X' as I'm going for more of a static pages feel so getting rid of the post bit would be better though not a huge deal.
 
Last edited:
You can also remove the "posted on by" part as you did with date. Actually you can remove the whole printf() function with all its variables.

If the message remains somewhere else (e.g. in single posts), you also need to remove it from the content-single.php.
 
The below given post suggest to check in other places like index.php, page,php, archives.php..

Code:
http://www.wpthemes.com/wp-hacks-how-to-remove-date-from-posts/
Also you may get a solution reading these threads..

Code:
site:en.forums.wordpress.com How do I remove the date from posts
 
That's not the OP's case. Haven't you seen his single.php? All the mentioned above files (index.php, page,php, archives.php) will not contain anything to fix (in this particular case) - checking them is just a waste of time.
 
Well I just happened to be reading the hacks one myself by coincidence and I took a look in archives and it has alot of time/date info so could it be causing the issue or not?

Code:
<?php
/**
 * @package WordPress
 * @subpackage JohnLoan
 */

get_header(); ?>

        <section id="primary">
            <div id="content" role="main">

                <?php the_post(); ?>

                <header class="page-header">
                    <h1 class="page-title">
                        <?php if ( is_day() ) : ?>
                            <?php printf( __( 'Daily Archives: <span>%s</span>', 'johnloan' ), get_the_date() ); ?>
                        <?php elseif ( is_month() ) : ?>
                            <?php printf( __( 'Monthly Archives: <span>%s</span>', 'johnloan' ), get_the_date( 'F Y' ) ); ?>
                        <?php elseif ( is_year() ) : ?>
                            <?php printf( __( 'Yearly Archives: <span>%s</span>', 'johnloan' ), get_the_date( 'Y' ) ); ?>
                        <?php else : ?>
                            <?php _e( 'Blog Archives', 'johnloan' ); ?>
                        <?php endif; ?>
                    </h1>
                </header>

                <?php rewind_posts(); ?>
                
                <?php johnloan_content_nav( 'nav-above' ); ?>

                <?php /* Start the Loop */ ?>
                <?php while ( have_posts() ) : the_post(); ?>                

                    <?php get_template_part( 'content', get_post_format() ); ?>

                <?php endwhile; ?>

                <?php johnloan_content_nav( 'nav-below' ); ?>                

            </div><!-- #content -->

            <?php get_sidebar(); ?>
        </section><!-- #primary -->

<?php get_footer(); ?>
 
You said you want to remove the date from single posts. Right? If so, check your content-single.php.

As about your archives.php, so it's a way different story.
 
You said you want to remove the date from single posts. Right? If so, check your content-single.php.

As about your archives.php, so it's a way different story.

Boom! there it is :)

That got it.

Cheers.
 
Maybe you don't have to remove the line to make the date disappear. Simply put double slash "//" in it. Example:

Code:
<?php // the_date(); ?>

So next time if you decide to show the post date, you don't have to google it. Just remove the // :D
 
Back
Top