我想創建一個循環,獲取特定類別ID的帖子。 第一篇文章是這個類別的最新文章,其他文章是下面的文章。WordPress的 - 特定類別後循環
所以我有一個類別的ID =「190」,如何獲得這個職位,按照這種設計? >>Check the Design here
<!-- Featured Post -->
<div class="module-one-typo">
<a href="#"><img src="img/sample/370x250.png?1491474115266" alt=""></a>
<h3><a href="#"><b>Trump names climate change skeptic and Oil industry ally to lead the EPA</b></a></h3>
<h5>
<span><i class="fa fa-calendar"></i> November 02, 2017 </span>
<span> <i class="fa fa-comments-o"></i> 10</span>
<span> Eyad Ashraf</span>
</h5>
<p>Lorem ipsum dolor sit amet, consectmagna aliqua. ex ea commodo consequat. Duis aute irure etur adipisicing elit, dolor in reprehenderit in voluptate velit .</p>
</div>
<!-- /Featured Post -->
<!-- Older post Loop -->
<div class="module-two-strips">
<div class="module-one-strip row align-middle">
<div class="columns shrink"><a href="#"><img src="img/sample/100x80.png" alt=""></a></div>
<div class="columns">
<h5><a href="#"><b>The first Pirate Party was created in Sweden in 2006</b></a></h5>
<h5>
<span><i class="fa fa-calendar"></i> November 02, 2017 </span>
<span> <i class="fa fa-comments-o"></i> 100</span>
</h5>
</div>
</div>
<div class="module-one-strip row align-middle">
<div class="columns shrink"><a href="#"><img src="img/sample/100x80.png" alt=""></a></div>
<div class="columns">
<h5><a href="#"><b>The first Pirate Party was created in Sweden in 2006</b></a></h5>
<h5>
<span><i class="fa fa-calendar"></i> November 02, 2017 </span>
<span> <i class="fa fa-comments-o"></i> 100</span>
</h5>
</div>
</div>
<div class="module-one-strip row align-middle">
<div class="columns shrink"><a href="#"><img src="img/sample/100x80.png" alt=""></a></div>
<div class="columns">
<h5><a href="#"><b>The first Pirate Party was created in Sweden in 2006</b></a></h5>
<h5>
<span><i class="fa fa-calendar"></i> November 02, 2017 </span>
<span> <i class="fa fa-comments-o"></i> 100</span>
</h5>
</div>
</div>
<div class="module-one-strip row align-middle">
<div class="columns shrink"><a href="#"><img src="img/sample/100x80.png" alt=""></a></div>
<div class="columns">
<h5><a href="#"><b>The first Pirate Party was created in Sweden in 2006</b></a></h5>
<h5>
<span><i class="fa fa-calendar"></i> November 02, 2017 </span>
<span> <i class="fa fa-comments-o"></i> 100</span>
</h5>
</div>
</div>
</div>
<!-- Older post Loop -->
更新:
我有,我會採取從VC類別ID,並創建該元素的視覺作曲家簡碼功能。 ($類是類別ID值)
<?php
$args = array(
'cat' => 194, //your category ID
'posts_per_page' => 10
);
$the_query = new WP_Query($args);
?>
<?php if ($the_query->have_posts()) : while ($the_query->have_posts()) : the_post(); ?>
<h1><?php the_title(); ?> </h1>
<?php endwhile; else : ?>
<p><?php _e('Sorry, no posts matched your criteria.'); ?></p>
<?php endif; ?>
<!-- CUSTOM CONTENT -->
<?php
return ob_get_clean();
}
add_shortcode('et_module', 'et_module');
這是我到目前爲止測試,我得到這個錯誤。 PHP Error i'm getting
您是否嘗試過任何循環之前添加
? –對於該內存問題,您可以在wp-config.php中添加此項,並嘗試使用 //增加WP內存限制 define('WP_MAX_MEMORY_LIMIT','256M'); – Prabu
感謝它工作正常 –