Skip to content

Instantly share code, notes, and snippets.

@generatepress
Last active August 15, 2020 09:22
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/9986c15bbffafa0cc7e1 to your computer and use it in GitHub Desktop.
Save generatepress/9986c15bbffafa0cc7e1 to your computer and use it in GitHub Desktop.
generate_posted_on() without time updated/published schema tags
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">%2$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>', '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
),
sprintf( '<span class="author vcard" itemtype="http://schema.org/Person" itemscope="itemscope" itemprop="author">%1$s <a class="url fn n" href="%2$s" title="%3$s" rel="author" itemprop="url"><span class="author-name" itemprop="name">%4$s</span></a></span>',
__( 'by','generate'),
esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ),
esc_attr( sprintf( __( 'View all posts by %s', 'generate' ), get_the_author() ) ),
esc_html( get_the_author() )
)
);
}
endif;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment