Customize the structure of WP Discourse templates

Edit: I got it working and pasted the correct code below for anyone else with same challenge:

@angus After some reading I found the location to override the size of gravatar on WP Discourse comments.

in my functions.php I added this (but get error/see below):

// Customizes the comment_html template.

function my_wpd_comment_html( $input ) {
		ob_start();
		?>
		<li class="comment <?php echo $even ? 'even' : 'odd'; ?> depth-1">
			<article class="comment-body">
				<footer class="comment-meta">
					<div class="comment-author vcard">
						<img alt="Avatar for {username}" src="{avatar_url}" class="avatar avatar-64 photo avatar-default"
							 height="24"
							 width="24">
						<b class="fn"><a href="{topic_url}" rel="external"
										 class="url">{username}</a></b>
						<span class="says screen-reader-text"><?php echo esc_html( 'says:', 'wp-discourse' ); ?></span><!-- screen reader text -->
					</div>
					<div class="comment-metadata">
						<time datetime="{comment_created_at}">{comment_created_at}</time>
					</div>
				</footer>
				<div class="comment-content">{comment_body}</div>
			</article>
		</li>
		<?php
		$output = ob_get_clean();
 return $output;
	}

// Hook into the function from the plugin's code.
add_filter(  'discourse_comment_html', 'my_wpd_comment_html' );

Edit: it works now!
However, I get an error 500. I don’t have display errors enabled. About to set up and do that now in a sandbox to see the syntax error. But wanted to post the code here in case it was an obvious fix.

Thanks

1 Like