• Welcome to the all-new Kolakube support, the official place to get help for Marketers Delight, XFtoWP, CryptoWP, and other WordPress products! Please login with your account details to access members-only support forums.

Move the comment input textarea above the comment list

goodtacos

Member
Md
Messages
21
Reaction score
5
Hi,

I'd like to get some help figuring out moving the comment input textarea above the comment list (here's the image). I suspect that this can be done by typing a PHP code in functions.php.

If anyone is kind enough, I'd appreciate your help (my knowledge in PHP is none) if you could share your code!
 
Solution
Hi @goodtacos, my apologies for the delayed response but I have a solution for you. Thanks to a tweak I just released in MD5.5.7 we can now easily achieve this. First things first, go ahead to your WP admin > MD > Updates and update to 5.5.7.

Now in your child theme functions.php file, simply drop these two lines to switch the position of the comment form to go before the comments list:

PHP:
remove_action( 'md_hook_after_comments_list', 'md_comment_form' );
add_action( 'md_hook_before_comments_list', 'md_comment_form' );

The comment input is still at the very bottom, instead of above the comment list. Below is the content of functions.php.
In the first answer I wrote, I had actually misread your question...
Edit: I read your post too quickly and gave you a code snippet to achieve something different. I am revising my answer now!

Hi @goodtacos I worked this out for you to reorder the comments field like so. It does feel more natural this way.

Screen Shot 2022-12-31 at 11.54.29 AM.png

You can place this in your child theme functions.php file (ideally) or wherever you post custom snippets:

[CODE lang="php" title="Move message field to end of comments form"]/**
* Re-order Comment fields.
*
* @since 1.0
*/

function my_child_theme_comment_fields( $fields ) {
$comment = $fields['comment'];
$cookies = $fields['cookies'];

unset( $fields['comment'] );
unset( $fields['cookies'] );

$fields['comment'] = $comment;
$fields['cookies'] = $cookies;

return $fields;
}
add_filter( 'comment_form_fields', 'my_child_theme_comment_fields' );[/CODE]
 
Comment
Hi @Alex thank you for the reply! I put the code on the child theme's functions.php on a vanilla site (WP 6.1.1, MD 5.5.6) but it does not seem to have had any effect. The comment input is still at the very bottom, instead of above the comment list. Below is the content of functions.php.

COMMENT-SCREENSHOT.png

PHP:
<?php

// define constants
define( 'MD_CHILD_DIR', trailingslashit( get_stylesheet_directory() ) );
define( 'MD_CHILD_URL', trailingslashit( get_stylesheet_directory_uri() ) );

// include MD library and child theme files
require_once( get_template_directory() . '/lib/marketers-delight.php' );
require_once( 'loader.php' );

// include MD Drop-ins
include( 'dropins/related-posts/related-posts.php' );
include( 'dropins/videos/videos.php' );
include( 'dropins/page-blocks/page-blocks.php' );

/**
 * Custom : Re-order Comment fields.
 *
 * @since 1.0
 */

function my_child_theme_comment_fields( $fields ) {
    $comment = $fields['comment'];
    $cookies = $fields['cookies'];

    unset( $fields['comment'] );
    unset( $fields['cookies'] );

    $fields['comment'] = $comment;
    $fields['cookies'] = $cookies;

    return $fields;
}
add_filter( 'comment_form_fields', 'my_child_theme_comment_fields' );

// run MD design mode (rebuilds dynamic CSS from style.php on every page load)
//md_compile_css();
 
Comment
Hi @goodtacos, my apologies for the delayed response but I have a solution for you. Thanks to a tweak I just released in MD5.5.7 we can now easily achieve this. First things first, go ahead to your WP admin > MD > Updates and update to 5.5.7.

Now in your child theme functions.php file, simply drop these two lines to switch the position of the comment form to go before the comments list:

PHP:
remove_action( 'md_hook_after_comments_list', 'md_comment_form' );
add_action( 'md_hook_before_comments_list', 'md_comment_form' );

The comment input is still at the very bottom, instead of above the comment list. Below is the content of functions.php.
In the first answer I wrote, I had actually misread your question and assumed you wanted to do something different, which my first answer reflects. However, you can now follow the steps above to get your comments form the way you want it. Let me know how it works!
 
Comment
Solution
Back
Top