WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Twenty Ten: How to add time stamp to all posts? (8 posts)

  1. slilley
    Member
    Posted 1 year ago #

    Just been rebuilding my site into a WordPress site for the first time. Right now my posts are just getting a date stamp, but I want to add the time as well. Any way to do this in css? I've got a child theme running. Any help appreciated!
    http://www.recklesslistening.com

  2. alchymyth
    Forum Moderator
    Posted 1 year ago #

    add the function twentyten_posted_on() into your child theme's functions.php, and add the time output there;

    edited code:

    function twentyten_posted_on() {
    	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() . ' ' . get_the_time()
    		),
    		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' ) ),
    			esc_attr( sprintf( __( 'View all posts by %s', 'twentyten' ), get_the_author() ) ),
    			get_the_author()
    		)
    	);
    }

    this line is the only edit to the function:

    get_the_date() . ' ' . get_the_time()

    (untested)

  3. slilley
    Member
    Posted 1 year ago #

    That works! My only other question is, is it possible to add the word "at" between the date and the time?

    Thank you so much for your help!

  4. slilley
    Member
    Posted 1 year ago #

    I only ask about separating the date and time because right now they are on the same link.
    http://www.recklesslistening.com

  5. alchymyth
    Forum Moderator
    Posted 1 year ago #

    this is the line:

    get_the_date() . ' ' . get_the_time()

    right now there one space character between date and time;

    change to:

    get_the_date() . ' at ' . get_the_time()

  6. slilley
    Member
    Posted 1 year ago #

    Thanks -- that adds the word "at", but I still have the date and time on the same link. Anyway to separate them, or to remove the date link altogether?

  7. alchymyth
    Forum Moderator
    Posted 1 year ago #

    I only ask about separating the date and time because right now they are on the same link.

    Anyway to separate them, or to remove the date link altogether?

    to keep the same link but separate them visually:

    function twentyten_posted_on() {
    	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> at <a href="%1$s" rel="bookmark"><span class="entry-date entry-time">%4$s</span></a>',
    			get_permalink(),
    			esc_attr( get_the_time() ),
    			get_the_date(),
    			get_the_time()
    		),
    		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' ) ),
    			esc_attr( sprintf( __( 'View all posts by %s', 'twentyten' ), get_the_author() ) ),
    			get_the_author()
    		)
    	);
    }

    review http://php.net/manual/en/function.sprintf.php

  8. slilley
    Member
    Posted 1 year ago #

    Thank you -- you've been so helpful!

Topic Closed

This topic has been closed to new replies.

About this Topic