• ebizdame

    (@ebizdame)


    Hi, I am trying to create a last updated post date next to or instead of, the original date in WP. I want to do this on my demo blog which uses Twenty Twelve (or Twenty Fifteen). Online I found a suggestion, and many repeats of the same, which suggests to change a code in the single post, page and index php of the theme.

    The code which needs to be replaced is:
    <?php the_modified_time(‘F jS, Y’);?>

    Every article also said “or similar” when refering to the code that needs to be changed.

    For the life of me I cannot find this code and I am not sure what “or similar” would be.

    Can anyone help? PS I do not want to use a plugin.

    Thanks

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

    (@alchymyth)

    in a child theme of Twenty Twelve, in functions.php, create an edited version of the ‘twentytwelve_entry_meta()’ function;

    example:

    function twentytwelve_entry_meta() {
    	// Translators: used between list items, there is a space after the comma.
    	$categories_list = get_the_category_list( __( ', ', 'twentytwelve' ) );
    
    	// Translators: used between list items, there is a space after the comma.
    	$tag_list = get_the_tag_list( '', __( ', ', 'twentytwelve' ) );
    
    	$date = sprintf( '<a href="%1$s" title="%2$s" rel="bookmark"><time class="entry-date" datetime="%3$s">%4$s</time></a>',
    		esc_url( get_permalink() ),
    		esc_attr( get_the_modified_time() ),
    		esc_attr( get_the_modofied_date( 'c' ) ),
    		esc_html( get_the_modified_date() )
    	);
    
    	$author = sprintf( '<span class="author vcard"><a class="url fn n" href="%1$s" title="%2$s" rel="author">%3$s</a></span>',
    		esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ),
    		esc_attr( sprintf( __( 'View all posts by %s', 'twentytwelve' ), get_the_author() ) ),
    		get_the_author()
    	);
    
    	// Translators: 1 is category, 2 is tag, 3 is the date and 4 is the author's name.
    	if ( $tag_list ) {
    		$utility_text = __( 'This entry was posted in %1$s and tagged %2$s and last updated on  %3$s<span class="by-author"> by %4$s</span>.', 'twentytwelve' );
    	} elseif ( $categories_list ) {
    		$utility_text = __( 'This entry was posted in %1$s and last updated on %3$s<span class="by-author"> by %4$s</span>.', 'twentytwelve' );
    	} else {
    		$utility_text = __( 'This entry was last updated on %3$s<span class="by-author"> by %4$s</span>.', 'twentytwelve' );
    	}
    
    	printf(
    		$utility_text,
    		$categories_list,
    		$tag_list,
    		$date,
    		$author
    	);
    }
    Thread Starter ebizdame

    (@ebizdame)

    Hi Michael,

    thank you very much for your response. I am not very techie, and I think I will not create a child theme at this time.

    However, do you have an idea where to find the code which needs to be replaced ? The one below. I can’t find anything like this or even remotely resembling this on Twenty Twelve or Fifteen

    <?php the_modified_time(‘F jS, Y’);?> or similar as every article says to do.

    Once again, thanks

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘How To Display Last Updated Date In Posts in Twenty Twelve or Fifteen’ is closed to new replies.