WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Possible to remove date only from a selected post? (21 posts)

  1. Tara
    Member
    Posted 3 years ago #

    Hi all,
    I wonder if it's possible to remove date ("posted on" date) ONLY from a selected post.

    If it is, please guide how to go about implementing it. Thanks in advance.

  2. Peter_L
    Member
    Posted 3 years ago #

    every post has a unique ID
    which you can see either in the URL if you have the standard permalink settings or in the admin section (hover over the link and look on the bottom left in your browser status bar).

    you can use this id to:
    -if your theme allows it, set the css of this id to display:none
    (not very elegant but very efficient method)
    -or you can add a condition in your single-post.php (if you have one, else single.php or index.php, in that order) to not show the post date if id == id of the post you want

  3. Tara
    Member
    Posted 3 years ago #

    thanks Peter_L for your reply.

    I am sorry, forgot to mention I am using Twenty Ten.

  4. Peter_L
    Member
    Posted 3 years ago #

    well, in Twenty Ten theme,
    the date shows on the index.php archive.php category.php and single.php

    and you would have to tamper with the very complex loop.php file to make it go away
    (I would opt for the css solution)

    so, you want the date gone on all of these pages?

  5. Tara
    Member
    Posted 3 years ago #

    so, you want the date gone on all of these pages?

    N0.

    I want date gone for ONLY one particular post.

    I am using parmalinks, and the post id=220.

    Thanks again Peter_L for your time and help.

  6. Peter_L
    Member
    Posted 3 years ago #

    no, what I mean is
    if you go to the category page that particular post is in, it will show a date there too for that post
    same for the home page and archive page

    so, do you want the date gone on all these pages for this post?

  7. Tara
    Member
    Posted 3 years ago #

    so, do you want the date gone on all these pages for this post?

    Just the Home Page or all these pages. Does not matter, whatever is relatively easy.

    Thanks again Peter_L for your patience.

  8. Tara
    Member
    Posted 3 years ago #

    I changed the post in question to a sticky post, and tried the following solutions I found in the forum, but nothing worked.

    I tried adding to the style.css this:

    .sticky .post-date {
    visibility: hidden;
    }

    and this,

    .sticky .date {
    visibility: hidden;
    }

    and this,

    .sticky .date {
    display: none;
    }

    Nothing worked. Can anybody guide please? Thanks.

  9. Peter_L
    Member
    Posted 3 years ago #

    This should do it:

    #post-220 .entry-meta .meta-prep, #post-14 .entry-meta a{
        display: none;
    }
    #post-220 .entry-meta span.vcard a{
        display: inline;
    }

    This will remove the 'posted on date' and only leave the 'by author' part on the post id 220 on every page.
    Or at least it did so for me.

  10. chinmoy
    Member
    Posted 3 years ago #

    @t-p

    First you will take a backup of your functions.php file. Replace this twentyten_posted_on() function with my code. This function is already exists. Just modify it with code(it is unchecked code).

    function twentyten_posted_on() {
      if(is_page(220)){
        printf( __( '<span class="meta-sep">Posted by</span> %1$s', 'twentyten' ),
      		sprintf( '<span class="author vcard"><a class="url fn n" href="%1$s" title="%2$s">%3$s</a></span>',
      			get_author_posts_url( get_the_author_meta( 'ID' ) ),
      			sprintf( esc_attr__( 'View all posts by %s', 'twentyten' ), get_the_author() ),
      			get_the_author()
      		)
      	);
      }else{
        printf( __( '<span class="%1$s">Posted on</span> %2$s <span class="meta-sep">by</span> %3$s', 'twentyten' ),
      		'meta-prep meta-prep-author',
      		sprintf( '<a href="%1$s" title="%2$s" rel="bookmark"><span class="entry-date">%3$s</span></a>',
      			get_permalink(),
      			esc_attr( get_the_time() ),
      			get_the_date()
      		),
      		sprintf( '<span class="author vcard"><a class="url fn n" href="%1$s" title="%2$s">%3$s</a></span>',
      			get_author_posts_url( get_the_author_meta( 'ID' ) ),
      			sprintf( esc_attr__( 'View all posts by %s', 'twentyten' ), get_the_author() ),
      			get_the_author()
      		)
      	);
      }
    }
  11. Tara
    Member
    Posted 3 years ago #

    Thanks evrybody for your itime, help, and patience with this newbie.

    @Peter_L

    Your solution works!

    The problem (in my case) is that it now also removes "Leave a comment" link that I had after the author. Is it possible to preserve that?

    @chinmoy29 Ji

    I tried your code as you suggested, but it did not remove anything.

  12. Peter_L
    Member
    Posted 3 years ago #

    well, both mine and @chinmoy29 's solutions work on the pure twenty-ten theme

    I'd have to see your customized version (the public part) to answer that question.

  13. Tara
    Member
    Posted 3 years ago #

    @Peter_L,

    I'd have to see your customized version (the public part) to answer that question.

    What part would be "the public part"? Please pardon my ignorance.

    Thanks.

  14. Peter_L
    Member
    Posted 3 years ago #

    just show the link to your blog so I can see the html generated by wordpress
    or
    post the html inside the <div id="post-220" ...></div>

    @chinmoy29, I tried out the above solution you gave and I couldn't make it work either

  15. Tara
    Member
    Posted 3 years ago #

    <div id="post-220" class="post-220 post type-post hentry category-Test category-testing tag-sabh">
    <h2 class="entry-title">Testing</h2>

    <div class="entry-meta">
    <span class="meta-prep meta-prep-author">Posted on</span> <span class="entry-date">September 8, 2010</span> <span class="meta-sep">by</span> <span class="author vcard">http://www.Example.com/aboutsite.php#author">admin</span> | <span class="comments-link"><img style="vertical-align:-5px;" alt="comments" src="http://www.Example.com/wp/wp-content/themes/mytwenyten/images/comment.gif" height="16" width="16" /> Leave a comment</span>
    </div><!-- .entry-meta -->

    <div class="entry-content">
    <p>test site</p>
    </div><!-- .entry-content -->

  16. Peter_L
    Member
    Posted 3 years ago #

    #post-220 .entry-meta .meta-prep, #post-220 .entry-meta a{
        display: none;
    }
    #post-220 .entry-meta span.vcard a, #post-220 .entry-meta span.comments-link a{
        display: inline;
    }
  17. Tara
    Member
    Posted 3 years ago #

    genious!
    thanks for the help, time and patient Peter.

  18. alchymyth
    The Sweeper & Moderator
    Posted 3 years ago #

    a variation of @Peter_L's solution:

    #post-1029 .entry-meta .meta-prep, #post-1029 .entry-date{
        display: none;}
    #post-1029 .meta-sep:before {content: 'Posted  '}
  19. Tara
    Member
    Posted 3 years ago #

    Thanks alchymyth,

    Your solution also works!

    You guys are brilliant!

  20. macknonalds
    Member
    Posted 3 years ago #

    Maybe you can check Oozman's Date Remover plugin. http://oozman.com/oozing/ideas/archives/oozman-date-remover-wordpress-plugin

    It works great.

  21. The Sandman
    Member
    Posted 3 years ago #

    Thanks for the great tip!

    In addition to the date in Twenty Ten, I would also like to remove the "Posted by XX", "Posted in category" and "Leave a comment" for my sticky post.

    Could anyone advise how this could be achieved?

    Thanks in advance!

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags