WordPress猫头鹰Carousel添加图像问题 - PHP

时间:2016-01-31 15:38:13

标签: php wordpress owl-carousel

我正试图进一步加载要加载显示的新图像链接。

目前显示5个,但我们想要添加第6个&未来可能还有2或3个人。

我们遇到的问题是当我们添加第六个时,它会覆盖现有的一个。

任何人都可以帮忙,我怀疑是功能,允许我们添加更多?

由于

HTML

<div class="content">
<div class="visible-xs visible-sm" style="background: #367586;color: white;width: 100%;">
    <h2 style="color: white;padding: 20px;text-align: center;">Call us on <a style="text-decoration: none;color: white;" href="tel:0141999999">0131 344 4146</a></h2>
</div>
<div class="pageTitle">
    <h1><?php single_cat_title(); ?></h1>
</div>

<?php
    $posts =  get_posts('category='.$cat);
    vvwc_carouselList($posts);
?>

<div class="clearfix"></div>

PHP

function vvwc_carouselList($posts, $postId=null){
if(!empty($posts)){
    echo '
        <div class="nonCarousel">
            <ul class="list-inline">
    ';
        $x = 1;
        foreach($posts as $post){
            $active = '';
            $feature = '';
            if($postId == $post->ID){
                $active = 'active';
                $feature = 'feature';
            }
            if($x == 5 || $x == 1){
                ?>
                <div class='row'>
                <?php
            }
            echo '
                <li class="col-md-3 '.$feature.'">
                    <div class="'.$active.' carousel-border">
                        <div class="carousel-item">
                        <a  data-item="'.$post->ID.'" href="'.get_permalink($post->ID).'">
                ';
                            if(has_post_thumbnail($post->ID)){
                                echo get_the_post_thumbnail($post->ID);
                            }
                            echo "<div class='camperTitle'>" . strtoupper($post->post_title) . "</div>";
                echo '
                            </a>
                        </div>
                    </div>
                </li>
            ';

            if($x == 4 || $x == count($posts)+1 ){
                ?>
                </div>
                <?php
            }
            $x ++;
        }
    echo '
            </ul>
            <div class="clearfix"></div>
        </div>
    ';
}
echo '
    <div class="clearfix"></div>
    <script>
        jQuery(document).ready(function($){
            $(".carousel ul").owlCarousel({
                items: 4,
                pagination: false,
                navigation: true,
                navigationText: false,
                slideSpeed: 1000,
                rewindSpeed: 1000
            });
        });
    </script>
';

}

1 个答案:

答案 0 :(得分:0)

找到它,我换了:

$posts = get_posts('category='.$cat);

$posts = get_posts(array( 'category' =>15, 'orderby' => 'title', 'posts_per_page'=> 10, 'order' => 'ASC', ));