Site logo

Archived topic

Change comment's date location

5 replies · Started by Allen on July 27, 2021

Viewing posts 1–6 of 6

hi

a) Can I know how can I put author's comment date to right side. Currently its under author's name.
b) And how can I include "Day" and "Name of the day" (e.g Thursday) to the date. I tried to add in "Settings" but it will appear on my blog post as well. I only wish these to appear in comments section.

What I wish to achieved is shown in the screenshot.
Thank you!

Hi Allen,

a) Try this CSS:

.single-post .comment-author-info {
    display: flex;
    flex-wrap: wrap;
}
.single-post .comment-author.vcard {
    margin-right: 20px;
}

b) Can you add the Day in at Settings, and link us to your blog, so we can see what to do from there?

hi Ying!
a) Work perfectly! Thank you!!
b) I have added "day" and "Name of the day" to settings. Now just need to remove "Name of the day" from blog post's date.

Give this PHP a try:

add_filter( 'generate_post_date_output', function() {
	$time_string = '<time class="entry-date published" datetime="%1$s" itemprop="datePublished">%2$s  %5$s</time> ';

	if ( get_the_time( 'U' ) !== get_the_modified_time( 'U' ) ) {
		$time_string = '<time class="updated" datetime="%3$s" itemprop="dateModified">%4$s  %6$s</time> ' . $time_string;
	}

	$time_string = sprintf( $time_string,
		esc_attr( get_the_date( 'c' ) ),
		esc_html( get_the_date( 'Y年n月j日' ) ),
		esc_attr( get_the_modified_date( 'c' ) ),
		esc_html( get_the_modified_date( 'Y年n月j日 l' ) ),
		esc_html( get_the_date( '\a\t H:i' ) ),
		esc_html( get_the_modified_date( '\a\t H:i' ) )
	);

	return sprintf( '<span class="posted-on">Published: %1$s</span>', // WPCS: XSS ok, sanitization ok.
		sprintf( '<a href="%1$s" title="%2$s" rel="bookmark">%3$s</a>',
			esc_url( get_permalink() ),
			esc_attr( get_the_time() ),
			$time_string
		)
	);
} );

Adding PHP: https://docs.generatepress.com/article/adding-php/

c) Do you know how to display 周三 instead of 星期三? Just to prepare in case my client asked.

Not sure about this one, the translation is done by WordPress.
I would recommend reaching out to WordPress :)

Thank you, exactly what i want.

You are welcome :)

This archived topic is closed to new replies.