admin_url( 'admin-ajax.php' ), 'pending_msg' => __( '⧖ Thanks! Your comment will be available shortly. If you dont see it immediately, it is pending moderation.', 'wp-ajax-comments' ), 'error_msg' => __( '❌ Something went wrong. Please try again later.', 'wp-ajax-comments' ) ]); } }, 11 ); add_filter( 'comments_template', function( $theme_template ) { return !wp_doing_ajax() ? plugin_dir_path( __FILE__ ) . 'comments.php' : $theme_template; } ); add_action( 'wp_ajax_wac_load_comments', __NAMESPACE__ . '\wac_load_comments' ); add_action( 'wp_ajax_nopriv_wac_load_comments', __NAMESPACE__ . '\wac_load_comments' ); function wac_load_comments() { global $post; if( !headers_sent() ) { header( 'Content-Type: text/html; charset=' . get_option( 'blog_charset' ) ); status_header( 200 ); } $postID = filter_input( INPUT_GET, 'postID', FILTER_VALIDATE_INT ); $posts = new WP_Query( [ 'p' => $postID ] ); $GLOBALS['wp_query'] = $posts; if( have_posts() ) { while( have_posts() ) { the_post(); comments_template(); } } die(); }