1

enter image description here

The above is a snapshot where some classes and HTML arrangements(some flex and flexbox arrangements are needed) are generated by the WordPress →

<cite class="fn"></cite>
<span class="say"></span>

but unless I put in some div arrangement I can't implement the HTML design to my WordPress comment system →

<div class="some-class">
    <cite class="fn"></cite>
    <span class="say"></span>    
</div>

I am sure that there must be certain way to achieve this(Modify the core comment form HTML).

  • 1
    It depends entirely on the theme, as it can create its own template anywhere and and call it anything. Look for a file called comments.php in the theme folder, but if you're using a custom theme - which it appears you are - there's no way for us to help without knowing more information. – FluffyKitten Oct 1 '17 at 2:44
1

You can write your own custom HTML structure for comment listing. Inside your comments.php file, there will be a call to wp_list_comments() function. Find it, and pass your own function as its callback:

wp_list_comments( array( 'callback' => 'my_function' ) );

Now, create a callback function and start implementing your own HTML structure. This function accepts 3 arguments. Here is a basic example:

my_function( $comment, $args, $depth ){
    $GLOBALS['comment'] = $comment;
    // You have access to comment's ID and other
    // comment query methods here, such as comment_ID();
}
| improve this answer | |
  • Its just like creating short-code, Right? and then pass the output in between this → ob_start(); return ob_get_clean(); – The WP Intermediate Oct 1 '17 at 3:43
  • should I delete the default arguments inside the array → screencast.com/t/xktwJHG7uv? – The WP Intermediate Oct 1 '17 at 3:45
  • 1
    There's no need to delete them, or use output buffering. The link to codex page contains an example of how this function works. You can echo content too. – Jack Johansson Oct 1 '17 at 11:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.