I'm displaying a article on my page in Wordpress. Then right below that article, Im doing a foreach loop and displaying latest articles. Here is how it looks:
As you can see, "Jeffs Wedding Surprise" displays again in the bottom articles. How can I make it so the same article wont display again in my foreach loop that I'm viewing right now.
Here is how Im looping through the "Similar articles" at the bottom and my featured article:
<?php if( have_posts() ){
while( have_posts(['posts_per_page'=>100]) ){
$articles = the_post();
$thumb_id = get_post_thumbnail_id($articles);
$thumb_url_array = wp_get_attachment_image_src($thumb_id, 'thumbnail-size', true);
$thumb_url = $thumb_url_array[0];
?>
<?php } ?>
<div class="article-heading">
<h4><?php the_title(); ?></h4>
</div>
<div class="article-background">
<img src="<?=$thumb_url;?>">
<?php
$title = get_the_title();
$content = the_content();
if(strlen($content)>0){?>
<div class="article-details">
<?php $content ?>
</div>
<?php } ?>
</div>
<?php } ?>
<div class="similar-section">
<h3>Similar Articles</h3>
</div>
<?php foreach (get_posts(['post_type' => 'add_article', 'posts_per_page'=>3]) as $articles) {
$thumb_id = get_post_thumbnail_id($articles);
$thumb_url_array = wp_get_attachment_image_src($thumb_id, 'thumbnail-size', true);
$thumb_url = $thumb_url_array[0];
$url_to_project = "/previous_work/".$articles->post_name;
?>
<div class="col-md-4">
<a class="article-link" href="<?=$url_to_project;?>">
<div class="single-article-photo">
<img src="<?=$thumb_url;?>">
</div>
<div class="single-article">
<h6><?= $articles->post_title ?></h6>
<p><?= substr($articles->post_content,0,200) ?> <span style="text-transform: uppercase; text-decoration: underline">(Read More)</span>...</p>
</div>
</a>
</div>
<?php } ?>
