1

我正在尝试将每篇文章都包含到我在 WordPress 上的索引页面中,并让它们中的每一篇都使用包含的 CSS 进行样式设置。我可以查询所有帖子并显示它们,但实际上只有第一个帖子是样式化的。其余的继承了基本的 h1、h2、p 和其他通用样式,但它们没有继承每个样式的“box”类。所有信息都被放入一个“盒子”类,而不是像我希望的那样为每个帖子启动一个新的“盒子”类。对此的任何帮助将不胜感激。

这是我正在使用的代码

    <?php get_header(); ?>

    <div id="index-float-left">

<div class="box">

<?php query_posts( 'showposts=-1' ); ?>

<?php if (have_posts()) : while (have_posts()) : the_post();  ?>

    <div <?php post_class() ?> id="post-<?php the_ID(); ?>"> 

        <h1><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></h1>

        <p><?php the_content(); ?></p>

        <p class="post-date"><?php echo $post_date = get_the_date(); ?></p>

    </div>

</div> <!-- END BOX -->

    </div> <!-- FLOAT BOX BOX -->


    <?php endwhile; ?>

<?php else : ?>

    <h2>Not Found</h2>

<?php endif; ?>

<?php get_sidebar(); ?>

     <?php get_footer(); ?>
4

1 回答 1

0

“End Box”和“Fload Box Box”有问题。你可以这样试试:

<?php get_header(); ?>

<div id="index-float-left">

<?php query_posts( 'showposts=-1' ); ?>

<?php if (have_posts()) : while (have_posts()) : the_post();  ?>

<div class="box">
    <div <?php post_class() ?> id="post-<?php the_ID(); ?>"> 
        <h1><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></h1>
        <p><?php the_content(); ?></p>
        <p class="post-date"><?php echo $post_date = get_the_date(); ?></p>
    </div>
</div> <!-- END BOX -->   

<?php endwhile; ?>
<?php else : ?>

    <h2>Not Found</h2>

<?php endif; ?>

</div> <!-- FLOAT BOX BOX -->

<?php get_sidebar(); ?>
于 2012-12-03T22:01:18.613 回答