Insert ads between comments
I want to insert ads between comments.
function wpse_comments_ads_injection( $comment, $args, $depth ) {
static $count = 0;
if ( $count == 2 ) {
echo AD 1;
}
if ( $count == 5 ) {
echo AD 2;
}
$count++;
}
add_filter( 'wp_list_comments_args', function( $args ) {
if ( ! isset( $args['end-callback'] ) ) {
$args['end-callback'] = 'wpse_comments_ads_injection';
}
return $args;
} );
I wrote this code, but because of it the tag
!-- #comment-## --
/li
is deleted How will it be right?