Add time of the post next to the date
-
Hi there!
I have a website with Gazette theme.
I would like to add the time of the post, next to the date, on the page of the post but not on the homepage.
I am able to display the time instead of the date, editing the template-tag.php file, replacing “get_the_date” with “get_the_time”.
Here is the default code of the file :
if ( ! function_exists( 'gazette_posted_on' ) ) : /** * Prints HTML with meta information for the current post-date/time and author. */ function gazette_posted_on() { $time_string = '<time class="entry-date published updated" datetime="%1$s">%2$s</time>'; if ( get_the_time( 'U' ) !== get_the_modified_time( 'U' ) ) { $time_string = '<time class="entry-date published" datetime="%1$s">%2$s</time><time class="updated" datetime="%3$s">%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() ) ); $posted_on = sprintf( '<a href="%1$s" rel="bookmark">%2$s</a>', esc_url( get_permalink() ), $time_string ); $byline = sprintf( '<span class="author vcard"><a class="url fn n" href="%1$s">%2$s</a></span>', esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ), esc_html( get_the_author() ) ); if ( is_single() && ( 1 == get_theme_mod( 'gazette_author_bio' ) && get_the_author_meta( 'description' ) ) ) { echo '<span class="posted-on">' . $posted_on . '</span>'; } else { echo '<span class="posted-on">' . $posted_on . '</span><span class="byline"> ' . $byline . '</span>'; } } endif;
Two questions :
– how can I add the time next to the date ?
– how can I make this modification only on the posts and not the homepage ?Thank you!
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Add time of the post next to the date’ is closed to new replies.