我有一些代碼片段,我想檢查類別是否正確,如果帖子確實存在,此刻我有一個if_category()函數,然後查詢我所需的類別,但我認爲這些都是衝突,所以沒有我的職位的類別正在顯示,任何人都可以告訴我如何修復此代碼?如何在if..else語句中結合is_category()和query_posts()?
PHP
<?php if(is_category('Rainwater Harvesting Product')) { ?>
<!-- Related Projects -->
<?php query_posts('category_name=rainwater-harvesting-project&showposts=5'); ?>
<?php if (have_posts()) { ?>
<div class="aside-mod related-projects">
<div class="curved-ctn">
<h2 class="module-header">Related Projects</h2>
<ul class="project-list clearfix">
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<li class="project">
<a href="<?php the_permalink();?>" class="project">
<?php if (has_post_thumbnail()) {
the_post_thumbnail('thumbnail');
} ?>
<h3><?php the_title(); ?></h3>
<!-- <i class="icon-project"></i> -->
</a>
</li>
<?php endwhile; ?>
<?php endif; ?>
</ul>
</div>
</div>
<?php } ?>
<?php } ?>
<?php wp_reset_query(); ?>
有沒有在你的代碼,這樣多的空白,這是種族主義者。 –
道歉!只是整理代碼 – styler
@MadaraUchiha今天第一次讓我笑! –