• Resolved annmari1

    (@annmari1)


    I’d like to restyle the author/time stamp meta-data in the comments. I’m trying to remove the avatar for all authors and the “post author” image. I’d like the meta-data to be on a single line that says “Discussed by “author” on “date”. Ideally I’d like the reply to the comment link to be on the same line.

    I have pasted the ‘function twentytwelve_comment( $comment, $args, $depth )’ in functions.php for my child theme. I moved the header with the author meta-data below the comment content, but I can’t figure out how to make the other changes I want, in part because I can’t find the corresponding css, particularly for the positioning.

    Any ideas on how to proceed? I’ve spent a long time commenting out various bits of code and trying to write new css with little success.

    Thanks,
    Here’s the part of the function I’ve been looking at:

    <header class="comment-meta comment-author vcard">
    				<?php
    					  echo get_avatar( $comment, 44 );
    					printf( '<cite class="fn">%1$s %2$s</cite>',
    						get_comment_author_link(),
    						// If current post author is also comment author, make it known visually.
    						( $comment->user_id === $post->post_author ) ?  '<span> ' . __( 'Post author', 'twentytwelve' ) . '</span>'  : ''
    					);
    					printf(
    					'<a href="%1$s"><time datetime="%2$s">%3$s</time></a>',
    						esc_url( get_comment_link( $comment->comment_ID ) ),
    						get_comment_time( 'c' ),
    						/* translators: 1: date, 2: time */
    						sprintf( __( '%1$s at %2$s', 'twentytwelve' ), get_comment_date(), get_comment_time() )
    					);
    				?>
    			</header><!-- .comment-meta -->
Viewing 3 replies - 1 through 3 (of 3 total)
  • ..remove the avatar for all authors and the “post author” image.

    You can do that under Settings > Discussion by unchecking the “Show Avatars”. It now won’t output the image, but depends on the theme, there might be a bit of CSS to adjust.

    meta-data to be on a single line that says “Discussed by “author” on “date”.

    This is doable via CSS alone, with no template override.

    .author-description {
    	float: none;
    	width: auto;
    }
    
    .comments-area .avatar, .author-avatar {
    	display: none;
    }  
    
    .comments-area article header cite, .comments-area article header time {
    	display: inline;
    	margin-left: 0;
    }
    
    .comments-area article header cite:before {
    	content: "Discussed by ";
    }
    
    .comments-area article header time:before {
    	content: "on ";
    }

    ..the reply to the comment link to be on the same line.

    I don’t think that’s a good idea, it’s more logical that “Reply to” is availabe right after each comment.

    Thread Starter annmari1

    (@annmari1)

    Thanks! I finally got back to working on this project.

    Your CSS successfully moved the meta data where I wanted it, but then the “post author” identifier was on top of the time/date info. After some poking around I replaced this ternary operator

    ( $comment->user_id === $post->post_author ) ? '<span> ' . __( 'Post author', 'twentytwelve' ) . '</span>' : ' '

    with just the third expression

    ' '

    in the function twentytwelve_comment( $comment, $args, $depth )

    Unchecking the nesting options in the discussion settings got rid of the ‘reply.’

    There is an option not to show author avatars in twenty-twelve, but it doesn’t seem to get rid of the space where the avatar would go.

    Thanks for being awesome, paulwpxp.

    This will make [Post author] display line up correctly. Just add it to the above.

    .comments-area li.bypostauthor cite span {
    	position: relative; margin-right: 5px;
    }

    So, there is no need to touch the template, only CSS will do.

    But if you need to fix something up in the template already, it’s better if the markup alone would do without CSS hack.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘changing comment author metadata and avatar’ is closed to new replies.