Override comments.php template with plugin

How can I override default theme/WP Core comments.php template with my own in the plugin? I searched for different solutions, but they don’t work for me.

Or how to hook to the end of any post (even custom post type) to display my custom comments?

1 Answer
1

The comments_template hook:

add_filter( 'comments_template', function ( $template ) {
    return '/absolute/path/to/your/comments.php';
});

Leave a Comment