PHP Bootstrap row loop every 3 posts

前端 未结 2 1502
别那么骄傲
别那么骄傲 2021-01-27 06:31

Trying to display the custom posts on my archive page within a bootstrap row containing 3 columns then starting a new row, got the code but new to PHP and dont know where to put

相关标签:
2条回答
  • 2021-01-27 06:32

    In this part of code:

    <div class="col-md-4"<?php echo $bootstrapColWidth; ?>">
    

    You must get wrong bootstrap class like col-md-41, col-md-412. Correct you code by this way:

    <div class="col-md-<?php echo $bootstrapColWidth; ?>">
    
    0 讨论(0)
  • 2021-01-27 06:56

    First of all, you don't need to close and open row tag each 3 items. If you leave the code like this:

    <div class="row">
     <?php
            foreach ($rows as $row){
            ?>  
                    <div class="col-md-<?php echo $bootstrapColWidth; ?>">
                        <div class="thumbnail">
                            <img src="user_file/<?php echo $row->foto; ?>">
                        </div>
                    </div>
            <?php
            }
            ?>
    </div>
    

    you will get the same effect, but without the separation that a row tag involves. Notice that the line involving "col-md-4" has already changes in order to not create wrong col size usage.

    0 讨论(0)
提交回复
热议问题