WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Post date on two seperate lines (8 posts)

  1. camilleaubrey
    Member
    Posted 1 year ago #

    Hi, I'm using a Twenty Ten child theme. I can't figure out how to style/code my entry-meta onto 2 separate lines. Right now, it reads: "Date: 10.24.12" on one line, and I would like it to read "Oct" on one line and "24" on the line below.

    How do I do this? Please help!

    This is my blog link.

  2. Marvel Labs
    Member
    Posted 1 year ago #

    You need to create different CSS and change the format your theme uses to display the date.
    http://codex.wordpress.org/Formatting_Date_and_Time

  3. alchymyth
    The Sweeper & Moderator
    Posted 1 year ago #

    you need to edit the function twentyten_posted_on()
    in functions.php of Twenty Ten;

    which you seem to have done already;

    break the single get_the_date() into get_the_date('M') and get_the_date('d') or get_the_date('j')

    for details, please post the code as you have it now.

  4. camilleaubrey
    Member
    Posted 1 year ago #

    Hi,

    So I managed to change the date format but still can't "Oct" and "24" on 2 separate lines. Here is my functions.php code. Any ideas on how to do this??

    [code moderated - the posted code was corrupted;
    please use the pastebin for large amounts of code - http://codex.wordpress.org/Forum_Welcome#Posting_Code ]

  5. alchymyth
    The Sweeper & Moderator
    Posted 1 year ago #

    your posted code was corrupted by getting posted without being marked with the code buttons;
    also it is recommended to use the http://pastebin.com/ for larger amounts of code.

    please repost the code - http://codex.wordpress.org/Forum_Welcome#Posting_Code

  6. camilleaubrey
    Member
    Posted 1 year ago #

    My apologies! Here is the URL for the code in pastebin. Hopefully that works.

    http://pastebin.com/vtAVKw8V

  7. alchymyth
    The Sweeper & Moderator
    Posted 1 year ago #

    example (relevant section only; unnecessary code removed):

    function twentyten_posted_on() {
    	printf( __( '<span class="%1$s"></span> %2$s ', 'twentyten' ),
    		'meta-prep meta-prep-author',
    		sprintf( '<a href="%1$s" title="%2$s" rel="bookmark"></a><span class="entry-date">%3$s<br />%4$s</span>',
    			get_permalink(),
    			esc_attr( get_the_time() ),
    			'<span class="entry-date-month">'.get_the_date('M').'</span>',
    			'<span class="entry-date-day">'.get_the_date('d').'</span>'
    		)
    	);
    }

    as you can see, in this section, the date is output in two bits, separated by a linebreak:

    <span class="entry-date">%3$s<br />%4$s</span>

    and the two bits are generated here:

    '<span class="entry-date-month">'.get_the_date('M').'</span>',
    '<span class="entry-date-day">'.get_the_date('d').'</span>'

    these two lines was just this before:

    get_the_date()

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

  8. camilleaubrey
    Member
    Posted 1 year ago #

    Thanks! That worked beautifully.

Topic Closed

This topic has been closed to new replies.

About this Topic