Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@generatepress
Created April 7, 2015 07:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save generatepress/e1271b65688e8072a753 to your computer and use it in GitHub Desktop.
Save generatepress/e1271b65688e8072a753 to your computer and use it in GitHub Desktop.
generate_posted_on() without the author
if ( ! function_exists( 'generate_posted_on' ) ) :
/**
* Prints HTML with meta information for the current post-date/time and author.
*/
function generate_posted_on() {
if ( 'post' !== get_post_type() )
return;
$time_string = '<time class="entry-date published" datetime="%1$s" itemprop="datePublished">%2$s</time>';
if ( get_the_time( 'U' ) !== get_the_modified_time( 'U' ) )
$time_string .= '<time class="updated" datetime="%3$s" itemprop="dateModified">%4$s</time>';
$time_string = sprintf( $time_string,
esc_attr( get_the_date( 'c' ) ),
esc_html( get_the_date() ),
esc_attr( get_the_modified_date( 'c' ) ),
esc_html( get_the_modified_date() )
);
printf( __( '<span class="posted-on">%1$s</span>', 'generate' ),
sprintf( '<a href="%1$s" title="%2$s" rel="bookmark">%3$s</a>',
esc_url( get_permalink() ),
esc_attr( get_the_time() ),
$time_string
)
);
}
endif;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment