fahimmurshed

Comment fileds Order

Feb 23rd, 2021 (edited)
572
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // https://developer.wordpress.org/reference/functions/comment_form/
  2. //Comment Field Order
  3. add_filter( 'comment_form_fields', 'mo_comment_fields_custom_order' );
  4. function mo_comment_fields_custom_order( $fields ) {
  5.     $comment_field = $fields['comment'];
  6.     $author_field = $fields['author'];
  7.     $email_field = $fields['email'];
  8.     $url_field = $fields['url'];
  9.     $cookies_field = $fields['cookies'];
  10.     unset( $fields['comment'] );
  11.     unset( $fields['author'] );
  12.     unset( $fields['email'] );
  13.     unset( $fields['url'] );
  14.     unset( $fields['cookies'] );
  15.     // the order of fields is the order below, change it as needed:
  16.     $fields['author'] = $author_field;
  17.     $fields['email'] = $email_field;
  18.     $fields['url'] = $url_field;
  19.     $fields['comment'] = $comment_field;
  20.     $fields['cookies'] = $cookies_field;
  21.     // done ordering, now return the fields:
  22.     return $fields;
  23. }
RAW Paste Data