循环在不同的类的Wordpress博克文章

时间:2016-09-13 04:03:29

标签: php wordpress loops post

我真的需要你的帮助,因为我是PHP和WordPress的初学者(不会让人们问),如何在不同的类中制作一个PHP WordPress博客帖子循环,只有一个最新的帖子,如这个形象..

enter image description here

这里是html代码:



<!-- div that wrapped the large post -->

<div class="blog">
    <a href="#">
        <div class="row">
            <div class="col-lg-8 col-md-8 col-sm-12 col-xs-12">
                <img src="img/blog-super.jpg" class="img-responsive" />
            </div>
            <div class="col-lg-4 col-md-4 col-sm-12 col-xs-12">
                <div class="img-content text-left culturo-imagery">
                    <h2>The Only Thing Marketers Have to Fear Is Fear of Change</h2>
                    <div class="article-super">
                        Gladly, a customer-service software company, is offering organizations the opportunity to connect with customers on a variety of platforms. Gladly, a customer-service software company, is offering organizations the opportunity to connect with customers on a variety of platforms.variety of platforms.variety of platforms.
                    </div>
                    <div class="date">June, 20 2016</div>
                </div>
            </div>
        </div>
    </a>
</div>

<!-- div that wrapped the large post (end)  -->

<!-- div that wrapped the small posts -->

<div class="blog-sm">
    <div class="row">
        <div class="col-lg-4 col-md-4 col-sm-12 col-xs-12">
            <a href="">
                <div class="img-content text-left culturo-imagery">
                    <img src="img/blog1.jpg" class="img-responsive" />
                    <h4>We understand the unique pressures that business owners face.</h4>
                    <div class="article">
                        Gladly, a customer-service software company, is offering organizations the opportunity to connect with customers on a variety of platforms.
                    </div>
                    <div class="date">June, 20 2016</div>
                </div>
            </a>
        </div>
        <div class="col-lg-4 col-md-4  col-sm-12 col-xs-12">
            <a href="#">
                <div class="img-content text-left culturo-imagery">
                    <img src="img/blog2.jpg" class="img-responsive" />
                    <h4>On a complete understanding, our team delivers.</h4>
                    <div class="article">
                        Chris Grabarkiewicz of Luxottica Retail discusses how to overcome the challenge of synthesizing traditional marketing research information with Big Data to generate insights.
                    </div>
                    <div class="date">June, 20 2016</div>
                </div>
            </a>
        </div>
        <div class="col-lg-4 col-md-4  col-sm-12 col-xs-12">
            <a href="#">
                <div class="img-content text-left culturo-imagery">
                    <img src="img/blog3.jpg" class="img-responsive" />
                    <h4>And we can assist you in implementing the right solutions.</h4>
                    <div class="article">
                        Successful marketing is defined differently in different contexts. To understand its effect, researchers must consider all the factors that influence consumer choice, not just the marketing effort
                    </div>
                    <div class="date">June, 20 2016</div>
                </div>
            </a>
        </div>
    </div>
</div>

<!-- div that wrapped the small posts (end) -->
&#13;
&#13;
&#13;

非常感谢您的帮助,提前致谢:)

-Avril -

1 个答案:

答案 0 :(得分:0)

要捕获第一篇文章,您可以使用条件语句作为示例执行一个循环:

<?php if( $wp_query->current_post == 0 && !is_paged() ) : ?>
/*the output of the first post*?
<?php else : ?>
/*the output of all other posts*/
<?php endif; ?>
在你的情况下

   <?php if( $wp_query->current_post == 0 && !is_paged() ) : ?>
        <!-- div that wrapped the large post -->

<div class="blog">
    <a href="#">
        <div class="row">
            <div class="col-lg-8 col-md-8 col-sm-12 col-xs-12">
                <img src="img/blog-super.jpg" class="img-responsive" />
            </div>
            <div class="col-lg-4 col-md-4 col-sm-12 col-xs-12">
                <div class="img-content text-left culturo-imagery">
                    <h2>The Only Thing Marketers Have to Fear Is Fear of Change</h2>
                    <div class="article-super">
                        Gladly, a customer-service software company, is offering organizations the opportunity to connect with customers on a variety of platforms. Gladly, a customer-service software company, is offering organizations the opportunity to connect with customers on a variety of platforms.variety of platforms.variety of platforms.
                    </div>
                    <div class="date">June, 20 2016</div>
                </div>
            </div>
        </div>
    </a>
</div>
    <div class="blog-sm">
    <div class="row">
<!-- div that wrapped the large post (end)  -->
        <?php else : ?>

        <div class="col-lg-4 col-md-4 col-sm-12 col-xs-12">
            <a href="">
                <div class="img-content text-left culturo-imagery">
                    <img src="img/blog1.jpg" class="img-responsive" />
                    <h4>We understand the unique pressures that business owners face.</h4>
                    <div class="article">
                        Gladly, a customer-service software company, is offering organizations the opportunity to connect with customers on a variety of platforms.
                    </div>
                    <div class="date">June, 20 2016</div>
                </div>
            </a>
        </div>
        <?php endif; ?>
</div>
</div>

我还建议您阅读这篇文章:Different style for the first post