So you have two loops : the main loop and the second one using $query
.
You want to compare if at some point of your second loop there’s a match between current post (inside the loop) and the processed post inside the $query
loop.
Am I right ?
Instead of checking permalinks I would propose to check IDs.
So on the first loop you create a variable with the current post id :
$current_post_id = $post->ID;
and in your second loop you just compare :
if($query->have_posts()) : while ($query->have_posts()) : $query->the_post();
if( $current_post_id === $post->ID ) {
echo $post->ID;
} else {
echo "not found";
}
endwhile; wp_reset_postdata(); endif;
Not sure that is what you’re looking for, let us know.
PS: I should add to use a more specific name for your query, just to avoid name collision from a plugin or anything, like $my_prefix_query