• Hi everybody.

    I’m using Twenty Eleven and I would like to display the date in a dedicated box placed on the side of posts.

    Is there an easy way to do this?

    Thanks

Viewing 5 replies - 1 through 5 (of 5 total)
  • make sure to work with a child theme of Twenty Eleven:
    http://codex.wordpress.org/Child_Themes

    there is something to start with:
    http://wordpress.org/support/topic/how-to-add-twenty-eleven-post-date-images?replies=1

    Thread Starter superciccio14

    (@superciccio14)

    Ok, I followed that tutorial. I have 2 questions:

    A. why the date displayed is always “Jan 01”?

    B. Once fixed point A, how can I change date format from English to Italian?

    Thread Starter superciccio14

    (@superciccio14)

    OK for point B I modified functions.php as follows

    if ( ! function_exists( 'raindrops_posted_date' ) ) :
    function raindrops_posted_date() {
    ?>
    <h2 class="title-date"><a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Permalink to %s', 'twentyeleven' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark"><?php the_title(); ?></a></h2>
    <?php
    global $post;
    $day = date( 'd',strtotime( esc_html( get_the_date() ) ) );
    $month = date( 'M',strtotime( esc_html( get_the_date() )) );
    
    		switch ($month) {
    		    case 'Jan':
    		        $month = 'Gen';
    		        break;
                    /* and so on ... */
    		}
    
    ?>
    <div class="post-date">
    <span class="post-month"><?php echo $month; ?></span>
    <span class="post-day"><?php echo $day; ?></span>
    </div>
    <?php
    }
    endif;

    but I can’t understand why every post is tagged by January, 1st…

    try to change those lines:

    $day = date( 'd',strtotime( esc_html( get_the_date() ) ) );
    $month = date( 'M',strtotime( esc_html( get_the_date() )) );

    to:

    $day = get_the_date( 'd' );
    $month = get_the_date( 'M' );

    (untested, as the original code was working in my test)

    Thread Starter superciccio14

    (@superciccio14)

    OK perfetct now it works!

    Another question on functions.php. The second function of that code can be omitted? The code is:

    if (!function_exists( 'twentyeleven_posted_on' ) ) :
    /**
     * Create our own twentyeleven_posted_on to override parent function in our child theme
     */
    function twentyeleven_posted_on() {
    	printf( __('<span class="by-author"> <span class="sep">Posted by </span> <span class="author vcard"><a href="%1$s" title="%2$s" rel="author">%3$s</a></span></span>', 'twentyeleven' ),
    		esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ),
    		esc_attr( sprintf( __( 'View all posts by %s', 'twentyeleven' ), get_the_author() ) ),
    		get_the_author()
    	);
    }
    endif;

    If I omit

    twentyeleven_posted_on

    functions, the child theme inherits the posted_on properties of Twenty Eleven. Can I omit this portion of code without any problem?

    thanks

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Add a date box on the side of posts’ is closed to new replies.