我在Wordpress的頁面上顯示文章。然後就在那篇文章的下面,我正在做一個foreach循環並顯示最新的文章。下面是它的外觀:在文章頁面上隱藏重複的文章 - Wordpress
正如你所看到的,「傑夫斯婚禮驚喜」在底部的文章再次顯示。我怎樣才能讓它在我現在正在查看的foreach循環中再次顯示相同的文章。
這裏是如何林循環通過底部的「相關文章」和我的精選文章:
<?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 } ?>