2012-10-11 25 views
0

我試圖在我用boostrap響應框架開發的主題中顯示自定義帖子類型。除了我無法讓我的自定義帖子類型正確顯示的事實之外,一切都很好。我正在循環帖子類型,無法結束我的<div>的結果,頁腳被推到左側。請看:自定義帖子類型顯示不正確

<?php 
$query = new WP_Query(array('post_type'=>'services','posts_per_page'=>'5')); 
while ($query->have_posts()) : $query->the_post();?> 

<!-- Post Start --> 
<div class="row"> 
<div class="span2"> 
<?php the_post_thumbnail(array(150,150), array('class'=>'service-image')); ?> 
<h2><a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>"> 
<?php the_title(); ?></h2></a> 
<p><?php the_content(); ?></p> 
<p><a class="btn" href="<?php the_permalink(); ?>">View details &raquo;</a></p> 
</div> 

<?php endwhile; wp_reset_query(); ?></div></div></div></div></div> 
<!-- Post End --> 

我要我疊在</div>查詢的末端,以自定義後,才能正確顯示和頁腳返回到它應有的位置。我希望有人能看到我的錯誤,因爲我迷路了。任何幫助或指導都會很棒。主題可在crothersenvironmental.com開發中看到。在現場,我已經刪除了所有結束div以進行故障排除。

在此先感謝。

回答

0
  • 作爲加恩說,你格應該是在循環之前
  • 你不應該使用<p>標籤與the_content()
  • </a>關閉標籤前應</h2>

您可以嘗試:

<div class="row"> 
    <?php 
    $query = new WP_Query(array('post_type'=>'services','posts_per_page'=>'5')); 
    while ($query->have_posts()) : $query->the_post(); ?> 

    <!-- Post Start --> 
    <div class="span2"> 
     <?php the_post_thumbnail(array(150,150), array('class'=>'service-image')); ?> 
     <h2><a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>"> 
     <?php the_title(); ?></a></h2> 
     <div><?php the_content(); ?></div> 
     <p><a class="btn" href="<?php the_permalink(); ?>">View details &raquo;</a></p> 
    </div> 
    <!-- Post End --> 

    <?php endwhile; wp_reset_query(); ?> 
</div> 
0

您的第一行是否應該在循環之外聲明?此刻,每個帖子都會循環一次,但在循環過程中並未關閉。

<div class="row"> 
<?php 
$query = new WP_Query(array('post_type'=>'services','posts_per_page'=>'5')); 
while ($query->have_posts()) : $query->the_post();?> 

<!-- Post Start --> 
<div class="span2"> 
<?php the_post_thumbnail(array(150,150), array('class'=>'service-image')); ?> 
<h2><a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>"> 
<?php the_title(); ?></h2></a> 
<p><?php the_content(); ?></p> 
<p><a class="btn" href="<?php the_permalink(); ?>">View details &raquo;</a></p> 
</div><!--span2--> 

<?php endwhile; wp_reset_query(); ?></div><!--row--></div></div></div></div> 
<!-- Post End --> 
+0

這兩個答案都是正確的。我不相信我以前沒有看到過。我想是在午夜之後。萬分感謝! – David

相關問題