Hey there everyone. I have recently begun tweaking the new default wp theme, twenty ten. I was working on changing the way the post date and time is displayed when I realized that the loop() function calls for twentyten_posted_on(); where said info is to be displayed. So I eventually found said function inside functions.php. So far so good. Here’s what it looks like:
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()
),
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()
)
);
}
The only thing I really care about is what goes inside <span class="entry-date">, which unfortunately in this case is this weird looking character combo: %3$s. This leads me here to ask you knowledgeable fellows how the hell do I break that single var or whatever that is into the actual ‘day’, ‘month’ and ‘year’ pieces so that I may have something like this:
<div class="day">$dayvar</div>
<div class="month">$monthvar</div>
<div class="year">$yearvar</div>
I need to be able to do the above so that I can appropriately format my date info and have the site look just the way I want it to.
For good references:
- Here is the static html + css page:
http://scninja.com - Here is the test page where I’m
transforming the static into a fully
functioning wordpress site:
http://test.scninja.com
Thanks in advance
G.Campos
The “%3$s” is notation that’s used inside the sprintf. “%3” means use the third variable argument (get_the_date()) as a string ($s).
So you could break apart that original span into three divs by changing the twentyten_posted_on function like this:
Or you could go into the get_the_date function and change it to return the date as the 3 divs.