Archived topic
Published or Updated Text and Icon for Date
19 replies · Started by Rohan Verma on August 5, 2020
Use this snippet instead:
add_filter( 'generate_post_date_output', function( $output, $time_string ) {
// Set Published Date string
$label = 'Published: ';
$time_string = '<span class="date-label">%5$s</span><time class="entry-date published" datetime="%1$s" itemprop="datePublished">%2$s</time>';
// Compare updated and published dates
$updated_time = get_the_modified_time( 'U' );
$published_time = get_the_time( 'U' ) + 86400;
// If updated then update Date string
if ( $updated_time > $published_time ) {
$time_string = '<span class="date-label">%5$s</span><time class="entry-date updated-date" datetime="%3$s" itemprop="dateModified">%4$s</time>';
$label = 'Last Updated: ';
}
$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() ),
$label
);
return sprintf( '<span class="posted-on">%s</span> ',
$time_string
);
}, 10, 2 );
And add this CSS:
.entry-meta .author-name,
.entry-meta .date-label {
font-weight: 700;
}
Thanks David. Seems good now.
Another thing I need to ask.
1. How can I change the single post category box text color?
2. For multiple categories, it shows in (comma) format like - News, Games. I want to show separate category boxes.
Current Look: https://www.gadgetheadline.com/ios-14-beta-4-whats-new/
I'm using this CSS.
.cat-links {
background: #f6f4ff;
padding: 6px 6px 6px;
margin-right: 6px;
border-radius: 2px;
font-weight: 700;
font-size: 15px;
text-transform: normal;
border-left: 0px solid;
}
Can you raise a new topic so we can Resolve this one please
Okay.
Thanks