Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/294.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
wordpress PHP使用引导旋转木马每页显示3张幻灯片_Php_Wordpress_Twitter Bootstrap 3 - Fatal编程技术网

wordpress PHP使用引导旋转木马每页显示3张幻灯片

wordpress PHP使用引导旋转木马每页显示3张幻灯片,php,wordpress,twitter-bootstrap-3,Php,Wordpress,Twitter Bootstrap 3,您好,我尝试使用引导转盘每页显示3张幻灯片,但当我使用wordpress php查询时,每页仅显示1张幻灯片:(要显示另一张幻灯片,我应该单击“下一页”…请参见此 我试着用php查询来编写这个代码。 我的php代码: 您编写了一个错误的sctipt,并使用了许多未经修饰的wordpress函数。内容rss函数已被弃用,使用内容提要,要显示帖子,您必须使用“每页帖子”,而不是显示帖子。我已经用适当的函数重写了您的脚本。从下面复制并粘贴它我已经检查了脚本和它的工作情况。如果你出了什么问题,请告诉

您好,我尝试使用引导转盘每页显示3张幻灯片,但当我使用wordpress php查询时,每页仅显示1张幻灯片:(要显示另一张幻灯片,我应该单击“下一页”…请参见此 我试着用php查询来编写这个代码。 我的php代码:



您编写了一个错误的sctipt,并使用了许多未经修饰的wordpress函数。
内容rss
函数已被弃用,使用
内容提要
,要显示帖子,您必须使用
“每页帖子”
,而不是
显示帖子
。我已经用适当的函数重写了您的脚本。从下面复制并粘贴它我已经检查了脚本和它的工作情况。如果你出了什么问题,请告诉我

<div class="carousel slide" id="myCarousel">
<div class="carousel-inner">
    <?php
    $counter=0;
    ?>
    <div class="item <?php if($counter==0){echo 'active';} ?>">
        <ul class="thumbnails">
            <?php
            $my_query = new WP_Query(array(
                'posts_per_page'   => 5,
                'cat' => '1',

                )
            );

            while ($my_query->have_posts()) : $my_query->the_post();

            $do_not_duplicate = $post->ID;?>

            <li class="col-sm-4">
                <div class="shakhes">
                    <a href="<?php the_permalink(); ?>"><?php the_post_thumbnail('shakhes') ?></a>

                    <div class="caption"><a href="<?php the_permalink(); ?>">
                        <h4><div class="livicon" data-name="chevron-left" data-size="30"  data-color="#555" data-hovercolor="#555" ></div><?php the_title(); ?></h4></a>
                        <p><?php the_content_feed('', TRUE, '', 20); ?></p>
                        <div class="moreshakhes">  <a href="<?php the_permalink(); ?>">مشاهده ادامه مطلب</a></div>
                    </div>
                </div>
            </li>
        <?php endwhile; ?>

    </ul>
</div>
<?php $counter++; ?>
</div>

<nav>
    <ul class="control-box pager">
        <li><a data-slide="prev" href="#myCarousel" class=""><i class="glyphicon glyphicon-chevron-right"></i></a></li>
        <li><a data-slide="next" href="#myCarousel" class=""><i class="glyphicon glyphicon-chevron-left"></i></a></li>
    </ul>
</nav>
<!-- /.control-box -->

</div><!-- /#myCarousel -->


您编写了一个错误的sctipt,并使用了许多未经修饰的wordpress函数。
内容rss
函数已被弃用,使用
内容提要
,要显示帖子,您必须使用
“每页帖子”
,而不是
显示帖子
。我已经用适当的函数重写了您的脚本。从下面复制并粘贴它我已经检查了脚本和它的工作情况。如果你出了什么问题,请告诉我

<div class="carousel slide" id="myCarousel">
<div class="carousel-inner">
    <?php
    $counter=0;
    ?>
    <div class="item <?php if($counter==0){echo 'active';} ?>">
        <ul class="thumbnails">
            <?php
            $my_query = new WP_Query(array(
                'posts_per_page'   => 5,
                'cat' => '1',

                )
            );

            while ($my_query->have_posts()) : $my_query->the_post();

            $do_not_duplicate = $post->ID;?>

            <li class="col-sm-4">
                <div class="shakhes">
                    <a href="<?php the_permalink(); ?>"><?php the_post_thumbnail('shakhes') ?></a>

                    <div class="caption"><a href="<?php the_permalink(); ?>">
                        <h4><div class="livicon" data-name="chevron-left" data-size="30"  data-color="#555" data-hovercolor="#555" ></div><?php the_title(); ?></h4></a>
                        <p><?php the_content_feed('', TRUE, '', 20); ?></p>
                        <div class="moreshakhes">  <a href="<?php the_permalink(); ?>">مشاهده ادامه مطلب</a></div>
                    </div>
                </div>
            </li>
        <?php endwhile; ?>

    </ul>
</div>
<?php $counter++; ?>
</div>

<nav>
    <ul class="control-box pager">
        <li><a data-slide="prev" href="#myCarousel" class=""><i class="glyphicon glyphicon-chevron-right"></i></a></li>
        <li><a data-slide="next" href="#myCarousel" class=""><i class="glyphicon glyphicon-chevron-left"></i></a></li>
    </ul>
</nav>
<!-- /.control-box -->

</div><!-- /#myCarousel -->


这就是我提出的解决方案:

<div id="myCarousel" class="carousel slide" data-ride="carousel" data-interval="0">
                <div class="carousel-inner">
                    <?php $args = array(
                        'post_type' => 'product',
                        'posts_per_page' => 8,
                    );
                    $query = new WP_Query( $args );
                    $i = 1;
                    $next_item = true;
                    while($query->have_posts()) : $query->the_post(); 
                        if ($i == 1) {
                            echo '<div class="item carousel-item active">';
                        } elseif ($next_item == true) {
                            echo '<div class="item carousel-item">';
                        }
                        ?>
                        <div class="col-sm-3">
                                    <div class="thumb-wrapper">
                                        <div class="img-box">
                                          <?php the_post_thumbnail();?>
                                            <h4><?php the_title();?></h4>
                                        </div>
                                        <div class="thumb-content">
                                            <?php the_excerpt();?>
                                            <a href="<?php the_permalink();?>" class="btn btn-primary">Read More</a>
                                        </div>                      
                                    </div>
                        </div>
                        <?php
                        $next_item = false;
                        if ($i % 4 == 0) {
                            echo '</div>';
                            $next_item = true;
                        }
                        $i++;
                    endwhile
                    ?>
                </div>
                <a class="carousel-control-prev pull-left" href="#myCarousel" data-slide="prev">
                    <i class="fa fa-angle-left"></i>
                </a>
                <a class="carousel-control-next pull-right" href="#myCarousel" data-slide="next">
                    <i class="fa fa-angle-right"></i>
                </a>
            </div>

这是我提出的解决方案:

<div id="myCarousel" class="carousel slide" data-ride="carousel" data-interval="0">
                <div class="carousel-inner">
                    <?php $args = array(
                        'post_type' => 'product',
                        'posts_per_page' => 8,
                    );
                    $query = new WP_Query( $args );
                    $i = 1;
                    $next_item = true;
                    while($query->have_posts()) : $query->the_post(); 
                        if ($i == 1) {
                            echo '<div class="item carousel-item active">';
                        } elseif ($next_item == true) {
                            echo '<div class="item carousel-item">';
                        }
                        ?>
                        <div class="col-sm-3">
                                    <div class="thumb-wrapper">
                                        <div class="img-box">
                                          <?php the_post_thumbnail();?>
                                            <h4><?php the_title();?></h4>
                                        </div>
                                        <div class="thumb-content">
                                            <?php the_excerpt();?>
                                            <a href="<?php the_permalink();?>" class="btn btn-primary">Read More</a>
                                        </div>                      
                                    </div>
                        </div>
                        <?php
                        $next_item = false;
                        if ($i % 4 == 0) {
                            echo '</div>';
                            $next_item = true;
                        }
                        $i++;
                    endwhile
                    ?>
                </div>
                <a class="carousel-control-prev pull-left" href="#myCarousel" data-slide="prev">
                    <i class="fa fa-angle-left"></i>
                </a>
                <a class="carousel-control-next pull-right" href="#myCarousel" data-slide="next">
                    <i class="fa fa-angle-right"></i>
                </a>
            </div>


这很好,但是如果迭代次数不能被3整除,那么最后一个
元素永远不会关闭。我建议计算总迭代次数并将整数保存为变量,然后说
if($I%4==0)| |($I==$count)echo“”
这很有效,但是如果迭代次数不能被3整除,那么最后一个
元素永远不会关闭。我建议计算总迭代次数并将整数保存为变量,然后说
如果($I%4==0)|($I==$count)echo“”