I'm using the following conditional code to check if any comments on a given post contains a certain string. -The word 'CHANGES' in this case. I have it working if I specify the comment_ID directly, but I'd like to have the code use the loop to check all the comments for a given post and apply the appropriate HTML ID.
<?php
if( have_posts() ) : while (have_posts()) : the_post(); ?>
<div id="post-<?php the_ID(); ?>" <?php post_class('col-md-6 box');?>>
<div class="post-box article"
<!-- custom code begins -->
<?php
$mystring = get_comment_text($comment_ID = 23);
$findme = 'CHANGES';
$pos = strpos($mystring, $findme);
if ($pos === false) : ?>
id="pendingcomment"
<?php else : ?>
id="notapprovedcomment"
<?php endif; ?>
I'm trying to replace the $mystring reference so that it looks at all of the comments for a post each time the loop cycles. Do I have to run a another loop inside that cycles through the comments everytime? If so, what would that look like?
Thanks in advance for your time!