我遇到了在Wordpress中創建自己的搜索循環的問題。我想實現的是,某些情況下,只顯示某些信息:Wordpress Loop問題
<?php while (have_posts()) : the_post(); echo '<div>'; ?>
<?php if (in_category('property')) { ?>
<h3><?php the_title(); ?></h3>
<?php the_field('main-image-description'); ?>
<span class="launch">
<a href="<?php the_permalink(); ?>" title="<?php printf(esc_attr__('Permalink to %s', 'boilerplate'), the_title_attribute('echo=0')); ?>" rel="bookmark">
<span class="link">click to launch</span>
<span class="launch-icon"></span>
</a>
</span>
<?php } ?>
<?php if (in_category('all-developments')) { ?>
<h3><?php the_title(); ?></h3>
<?php the_field('property-description'); ?>
<span class="launch-brochure">
<a href="<?php the_field('pdf-download-all-developments'); ?>" target="_blank">
<span class="link">Download Brochure</span>
<span class="launch-icon"></span>
</a>
</span>
<?php } ?>
<?php if (is_page()) { ?>
<h3><?php the_title(); ?></h3>
<?php the_content(); ?>
<span class="launch">
<a href="<?php the_permalink(); ?>" title="<?php printf(esc_attr__('Permalink to %s', 'boilerplate'), the_title_attribute('echo=0')); ?>" rel="bookmark">
<span class="link">click to launch</span>
<span class="launch-icon"></span>
</a>
</span>
<?php } ?>
<?php echo '</div>'; endwhile; ?>
即出現的問題,是永遠呈現在最上面的一個或兩個空標籤,這廢墟它的風格,每個div都有一個虛線邊框。有沒有告訴Wordpress如果不符合這些條件的方法,那麼不要顯示<div>
?
在此先感謝您的幫助!
JP
瑞恩,我想我有一棵樹木的時刻!感謝您的幫助! – JohnRobertPett
哈哈,相信我,我一直在那裏。希望這能幫助你! – Ryan
@ user1872510 - 不要忘記,你可以標記回答作爲答案;) – Ryan