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を削除しました。

前もって感謝します。

4

2 に答える 2

0

最初の行をループの外側で宣言するべきではありませんか?現時点では、投稿ごとに1回ループされていますが、ループ中に閉じられていません。

<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 -->
于 2012-10-11T14:15:40.713 に答える
0
  • gArnが言ったように、行divはループの前にある必要があります
  • <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>
于 2012-10-11T14:29:20.617 に答える