Forums

[resolved] Hide post date for single post? (6 posts)

  1. Paul Whitener Jr.
    Member
    Posted 3 years ago #

    I'm looking for a way to hide the post date for particular posts. For example, I have a "sticky post" on my index page that I don't want to display the date for. I would like the other posts on the page to show the date.

    Is there a way to set whether to show/hide the date on a post-by-post basis, or a way to hide the date on sticky posts only?

    Thanks!

  2. buddha trance
    Member
    Posted 3 years ago #

    I just tested this and it worked.

    On index.php, you will see something like
    <?php the_time('M jS, Y'); ?>

    Just use this, so that when the post is sticky, it won't display

    <?php if (!is_sticky() ) { ?>
    <?php the_time('M jS, Y'); ?>
    <?php }
    ?>
  3. Paul Whitener Jr.
    Member
    Posted 3 years ago #

    Nice, that worked perfectly. Thanks!

  4. julie24n24
    Member
    Posted 2 years ago #

    Thanks pwhitene, this is exactly what I was looking for. I've implemented and it works! Thanks a whole bunch.

    http://www.citygeisha.com

  5. Andy@YummyFavours
    Member
    Posted 2 years ago #

    Great work - it works perfectly on our basic, but modified Kubrick theme.

    Andy

  6. archeryimages.net
    Member
    Posted 2 years ago #

    Thanks! In my case, I wanted to erase all the things that are published by the theme if the post is sticky.
    So I set the if(!is_sticky()) around the <p> tag. So

    <p class="timestamp"><?php the_time('j F, Y (H:i)') ?> | <?php the_category(', ') ?> | By: <?php the_author(); ?><?php edit_post_link('[e]',' | ',''); ?></p>

    became:

    <?php if (!is_sticky() ) { ?>
    <p class="timestamp"><?php the_time('j F, Y (H:i)') ?> | <?php the_category(', ') ?> | By: <?php the_author(); ?><?php edit_post_link('[e]',' | ',''); ?></p>
    <?php } ?>

    Just for the search engine Visitors.. ;-)

Topic Closed

This topic has been closed to new replies.

About this Topic