【问题标题】:how to show last 5 post in wordpress using this bootstrap grid codes?如何使用此引导网格代码在 wordpress 中显示最后 5 个帖子?
【发布时间】:2020-05-17 19:16:03
【问题描述】:

我想动态地使用 WordPress 循环由 Bootstrap 4 编写的以下代码。 我想在下面的代码中显示最后 5 个帖子。像图片一样: https://i.stack.imgur.com/n4fYa.jpg

<div class="container">
    <div class="row">
        <div class="col-md-6 d-flex align-items-md-stretch">
            <div class="jumbotron ">
                Lorem ipsum, or lipsum as it is sometimes known, is dummy text used in laying out print, graphic or web designs. The passage is attributed to an unknown typesetter in the 15th century who is thought to have scrambled parts of Cicero's De Finibus Bonorum et Malorum for use in a type specimen book.
            </div>
        </div>
        <div class="col-md-6">
            <div class="row">
                <div class="col-md-6">
                    <div class="jumbotron">
                        Lorem ipsum, or lipsum as it is sometimes known, is dummy text used in laying out print, graphic or web designs
                    </div>
                </div>
                <div class="col-md-6">
                    <div class="jumbotron">
                        Lorem ipsum, or lipsum as it is sometimes known, is dummy text used in laying out print, graphic or web designs
                    </div>
                </div>
                <div class="col-md-6">
                    <div class="jumbotron">
                        Lorem ipsum, or lipsum as it is sometimes known, is dummy text used in laying out print, graphic or web designs
                    </div>
                </div>
                <div class="col-md-6">
                    <div class="jumbotron">
                        Lorem ipsum, or lipsum as it is sometimes known, is dummy text used in laying out print, graphic or web designs
                    </div>
                </div>
            </div>
        </div>
    </div>

</div>

【问题讨论】:

    标签: wordpress twitter-bootstrap bootstrap-4


    【解决方案1】:

    你可以试试:

    <?php $posts = get_posts(array('posts_per_page' => 5)); ?>
    
    <div class="container">
        <div class="row">
            <div class="col-md-6 d-flex align-items-md-stretch">
                <div class="jumbotron">
                    <!-- Post 5 -->
                    <?php echo $posts[4]->post_title; ?>
                </div>
            </div>
            <div class="col-md-6">
                <div class="row">
                    <div class="col-md-6">
                        <div class="jumbotron">
                            <!-- Post 2 -->
                            <?php echo $posts[1]->post_title; ?>
                        </div>
                    </div>
                    <div class="col-md-6">
                        <div class="jumbotron">
                            <!-- Post 1 -->
                            <?php echo $posts[0]->post_title; ?>
                        </div>
                    </div>
                    <div class="col-md-6">
                        <div class="jumbotron">
                            <!-- Post 4 -->
                            <?php echo $posts[3]->post_title; ?>
                        </div>
                    </div>
                    <div class="col-md-6">
                        <div class="jumbotron">
                            <!-- Post 3 -->
                            <?php echo $posts[2]->post_title; ?>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2012-05-28
      • 1970-01-01
      • 1970-01-01
      • 2018-06-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多