Last active
March 26, 2016 18:14
-
-
Save generatepress/17e92621b6bf1140dafa to your computer and use it in GitHub Desktop.
generate_posted_on() with no link to date and author
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> <span class="byline">%2$s</span>', 'generatepress' ), | |
sprintf( '%1$s', | |
$time_string | |
), | |
sprintf( '<span class="author vcard" itemtype="http://schema.org/Person" itemscope="itemscope" itemprop="author">%1$s <span class="author-name" itemprop="name">%2$s</span></span>', | |
__( 'by','generatepress'), | |
esc_html( get_the_author() ) | |
) | |
); | |
} | |
endif; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment