Site logo

[Resolved] Change comment’s date location

Home Forums Support [Resolved] Change comment’s date location

Home Forums Support Change comment’s date location

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #1873268
    Allen

    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!

    #1873325
    Ying
    Staff
    Customer Support

    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?

    #1873379
    Allen

    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.

    #1873531
    Ying
    Staff
    Customer Support

    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 🙂

    #1873849
    Allen

    Thank you, exactly what i want.

    #1874881
    Ying
    Staff
    Customer Support

    You are welcome 🙂

Viewing 6 posts - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.