Change the markdown for comments (output from wp_list_comments)

Question

By using: wp_list_comments(), comments currently have this markdown:

<div id="comment-1" class="comment even thread-even depth-1">
    <div class="comment-author vcard"><cite class="fn">Anonymous</cite> <span class="says">says:</span></div>
    <div class="comment-meta commentmetadata">
        <a href="https://example.org/test/#comment-1">December 11, 2020 - 12:03 am</a> &nbsp;&nbsp;<a href="https://example.org/wp-admin/comment.php?action=editcomment&amp;c=1" class="comment-edit-link">
          (Edit)
        </a>
    </div>
    <p>Test</p>
    <div class="reply">
        <a rel="nofollow" href="#comment-1" data-commentid="1" data-postid="1133" data-belowelement="comment-1"
            data-respondelement="respond" data-replyto="Respond " aria-label="Respond " class="comment-reply-link">Svar
        </a>
    </div>
</div>

How do I change this markdown?

The things I would like to change:

  • Make it so the date is not a link
  • Remove all &nbsp;
  • All the extra properties, that I’m not using (data-commentid="1" and data-postid="1133")
  • Better class naming, like fn or vcard
  • Removing all ID and making it ID’s, to avoid potential clashes with other components.

And if you could explain how I could have found this answer myself, then it would be highly appreciated: What I should have looked for in the source code/documentation.


Attempts

  • Read the docs on wp_list_comments
  • Diving into the function-definition for wp_list_comments in the source-code. But it’s a big function. And nothing came up on when searching for meta.
  • Looked at documentation for get_comment_meta (but that was something different, taking a single comment ID as input.
0
Zeth 1 month 0 Answers 8 views 0

Leave an answer