$conf, $runtime; function_exists('chdir') AND chdir(APP_PATH); $r = 'mysql' == $conf['cache']['type'] ? website_set('runtime', $runtime) : cache_set('runtime', $runtime); } function runtime_truncate() { global $conf; 'mysql' == $conf['cache']['type'] ? website_set('runtime', '') : cache_delete('runtime'); } register_shutdown_function('runtime_save'); ?>php - Posts in two different columns Bootstrap|Programmer puzzle solving
最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

php - Posts in two different columns Bootstrap

matteradmin10PV0评论

I want the posts on the main page to be arranged in Bootstrap columns in this way:

I have this code, but instead of the first two posts, only one is displayed.

<?php get_header(); ?>
<?php $count_one = 1; ?>
<?php $count_two = 0; ?>
<?php if (have_posts()) : while (have_posts()) : the_post();
    if ($count_one % 5 == 1): ?>
        <div class="row one">
            <?php get_template_part('template-parts/content-one'); // For col-6 ?>
            <?php $count_one++; ?>
        </div>
    <?php else: ?>
        <?php if ($count_two % 3 == 0): ?>
            <div class="row two">
        <?php endif; ?>
        <?php get_template_part('template-parts/content-two'); // For col-4 ?>
        <?php $count_two++;
        if (($count_two % 3) == 0) { ?></div><!--row-->
        <?php } ?>
    <?php endif; ?>
    <?php $count_one++; endwhile; else: ?>
    <p><?php _e('We can&rsquo;t find what you&rsquo;re looking for.', THEME_SLUG); ?></p>
<?php endif;
if (($count_two % 3) == 1) { ?>
    </div><!--row-->
<?php } ?>
<?php get_footer(); ?>

Please tell me where the error is.

Articles related to this article

Post a comment

comment list (0)

  1. No comments so far