Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/247.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 将此循环添加到col-4引导网格布局中_Php_Wordpress_Bootstrap 4 - Fatal编程技术网

Php 将此循环添加到col-4引导网格布局中

Php 将此循环添加到col-4引导网格布局中,php,wordpress,bootstrap-4,Php,Wordpress,Bootstrap 4,嗨,伙计们,我正试图将这个WordPress循环格式化为col-4引导布局,但我运气不好。有人能帮忙吗?我试图将每个“桶顶行”div显示为col-4布局 <div class="container"> <?php // get all the categories from the database $cats = get_the_category(); // loop through the

嗨,伙计们,我正试图将这个WordPress循环格式化为col-4引导布局,但我运气不好。有人能帮忙吗?我试图将每个“桶顶行”div显示为col-4布局

 <div class="container">
<?php
            // get all the categories from the database
            $cats = get_the_category();

                // loop through the categries
                foreach ($cats as $cat) {
                    // setup the cateogory ID
                    $cat_id= $cat->term_id;
                    // Make a header for the cateogry
                    // echo "<h2>".$cat->name."</h2>";
                    // create a custom wordpress query
                    query_posts("cat=$cat_id&posts_per_page=10");
                    // start the wordpress loop!
                    if (have_posts()) : while (have_posts()) : the_post();
                    ?>



    <div class="bucket-top-row row">
        <div class="col-lg-4">
            <div class="bucket-wrapper-standard-top-row">
                <img class="image-bucket-standard" src="<?php echo get_template_directory_uri() . '/images/blog-images/hero-img-1.jpg'; ?>" />
               <h4 id="post-<?php the_ID(); ?>" class="bucket-text-standard">
                    <a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?></a></h4>
                <p class="bucket-paragraph">
                <?php /* the_permalink() */?>
                </p>
                <div class="author-text-bucket">
                    <div class="author-image six-sm">
                        <img class="author-img-post" src="<?php echo get_template_directory_uri() . '/images/author-headshots/fitness-mark.png'; ?>" />
                    </div> <span class="author-name-post-bucket "><?php> the_author(); ?></span>
                    <span class="bucket-category"><?php> the_category(); ?></span>

                    <div class="lower-bucket-text">
                        <span class="author-job-title-bucket "><?php> the_author_nickname(); ?></span>
                        <span class="bucket-read-time">3min read</span>
                    </div>
                    <div class="underline-bucket"></div>
                </div>
            </div>
        </div>
</div>



<?php endwhile; endif; // done our wordpress loop. Will start again for each category ?>
                <?php } // done the foreach statement ?>

" />

" />

您的问题没有答案,但我建议您不要在循环中使用sql查询!你的回答给作者树立了一个坏榜样
<div class="container">
    <div class="bucket-top-row row">
        <?php
        // get all the categories from the database
        $cats = get_the_category();

        // loop through the categries
        foreach ($cats as $cat) {
        // setup the cateogory ID
        $cat_id= $cat->term_id;
        // Make a header for the cateogry
        // echo "<h2>".$cat->name."</h2>";
        // create a custom wordpress query
        query_posts("cat=$cat_id&posts_per_page=10");
        // start the wordpress loop!
        if (have_posts()) : while (have_posts()) : the_post();
        ?>



        <div class="col-lg-4">
            <div class="bucket-wrapper-standard-top-row">
                <img class="image-bucket-standard" src="<?php echo get_template_directory_uri() . '/images/blog-images/hero-img-1.jpg'; ?>" />
                <h4 id="post-<?php the_ID(); ?>" class="bucket-text-standard">
                    <a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?></a></h4>
                    <p class="bucket-paragraph">
                        <?php /* the_permalink() */?>
                    </p>
                    <div class="author-text-bucket">
                        <div class="author-image six-sm">
                            <img class="author-img-post" src="<?php echo get_template_directory_uri() . '/images/author-headshots/fitness-mark.png'; ?>" />
                        </div> <span class="author-name-post-bucket "><?php> the_author(); ?></span>
                        <span class="bucket-category"><?php> the_category(); ?></span>

                        <div class="lower-bucket-text">
                            <span class="author-job-title-bucket "><?php> the_author_nickname(); ?></span>
                            <span class="bucket-read-time">3min read</span>
                        </div>
                        <div class="underline-bucket"></div>
                    </div>
                </div>
            </div>



            <?php endwhile; endif; // done our wordpress loop. Will start again for each category ?>
            <?php } // done the foreach statement ?>
        </div>