Support » Themes and Templates » Twenty Ten: How to add time stamp to all posts?

  • Resolved slilley

    (@slilley)


    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

Viewing 7 replies - 1 through 7 (of 7 total)
  • Michael

    (@alchymyth)

    Forum Moderator

    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)

    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!

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

    Michael

    (@alchymyth)

    Forum Moderator

    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()

    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?

    Michael

    (@alchymyth)

    Forum Moderator

    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

    Thank you — you’ve been so helpful!

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Twenty Ten: How to add time stamp to all posts?’ is closed to new replies.