0

我的 wordpress 博客中有 10 篇文章,我想要类似的内容: div class="something1" post1 post5 post9 /div

div class="something2" post2 post6 post10 /div div class="something3" post3 post7 post4 post8 /div

我不知道,但我必须它,请帮助。

4

1 回答 1

0

在您的循环中,您需要使用 php.ini 增加您的 div。我没有对此进行测试,但这应该可以工作:

<div class="yourClass">
<?php
    $myCustomClass = 0;
    $args = array
    (
        'posts_per_page' => 4,
        'orderby'     => 'name',
        'order'       => 'DEC',
        'post_type'   => 'post',
        'post_status' => 'publish'
    );
    $loop = new WP_Query( $args );

    while ( $loop->have_posts() ) : $loop->the_post(); ?>
        <?php $myCustomClass++ ?>

            <div class="myCustomClass-<?php echo $myCustomClass;?>">

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

                <div class="my-post-content">

                    <?php the_content(); ?>

                </div>

            </div>
<? endwhile; ?>
</div>
于 2012-08-15T09:27:15.987 回答