1
我需要在類別中顯示標題,並且只有在WordPress中的類別中有帖子時才能顯示該標題。標題不應放在每個帖子上。它如何解決?僅在WordPress中的類別中有帖子時顯示標題
我現在的代碼:
<?php query_posts('category_name=onestar&showposts=5'); ?>
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<div class="wrapper orangecolor">
<article class="intro">
<h2><?php the_title(); ?></h2>
<div><?php the_content(); ?></div>
</article>
</div>
<?php endwhile; ?>
<?php endif; ?>
你應該while循環前添加標題。 –
昨天我在WordPress的支持論壇上發現了類似於它的東西,其標題在「:while」之前,但最終出現在PHP錯誤中。它應該如何編碼? –