Enable threaded comments

WordPress has support for threaded comments, but you have to enable it yourself, by adding a script to your head. You can use WordPress built in function wp_enqueue_script() to load the script, by adding this snippet to your functions.php.

When the script is loaded, you have to activate the threaded comments in the settings tab in WordPress admin, under Settings > Discussion. Click Enable threaded (nested) comments and choose the level of nested comments you want.

Code Snippet:

<?php
function enable_threaded_comments(){
    if (is_singular() AND comments_open() AND (get_option('thread_comments') == 1)) {
       wp_enqueue_script('comment-reply');
    }
}
add_action('get_header', 'enable_threaded_comments');
?>

Posted in Comments