[英]WordPress Query_Posts not Working in Widget Area
我有一個自定義帖子類型“項目”。 我試圖在小部件區域中顯示它們,但這似乎需要很長時間而沒有顯示任何內容。 只是一個加載微調器。 我的代碼可能有什么問題?
<?php
query_posts([
'post_type' => ['projects'],
'posts_per_page' => 5,
'paged' = >$paged,
]);
?>
可能不是最整潔的方式,但對我有用。
// the query
$the_query = new WP_Query( array(
'post_type' => 'projects',
'posts_per_page' => 7,
));
?>
<?php if ( $the_query->have_posts() ) : ?>
<?php while ( $the_query->have_posts() ) : $the_query->the_post(); ?>
<h2 class="projecth2"> <?php the_title(); ?> </h2>
<?php the_excerpt(); ?>
<hr>
<?php endwhile; ?>
<?php wp_reset_postdata(); ?>
<?php else : ?>
<p><?php __('No Projects'); ?></p>
<?php endif; ?>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.