【问题标题】:Wordpress blog post looping on different classWordpress 博客文章在不同的类上循环
【发布时间】:2016-09-13 04:03:29
【问题描述】:

我真的需要你的帮助,因为我是 PHP 和 WordPress 的初学者(周围没有人问),如何在不同的类中制作一个 PHP WordPress 博客文章循环,只为一个像这张图片这样的最新文章。 .

这是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) -->

非常感谢您的帮助,在此先感谢 :)

-艾薇儿-

【问题讨论】:

    标签: php wordpress loops post


    【解决方案1】:

    要赶上第一篇文章,您可以使用条件语句做一个循环作为示例:

    <?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

    【讨论】:

    • 谢谢之前,好的..让我试试:)
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2019-04-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-09-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多