在php中使列表从静态列表变为动态列表

在php中使列表从静态列表变为动态列表,php,html,Php,Html,我正在用php将静态html站点转换为动态站点,我有一个,其中是静态添加的,即用户推荐,当添加新推荐时,我需要列表自动递增。i、 e如果有一个证明,则项目符号应为,对于2,项目符号为2,依此类推。我的html代码是: <ol class="carousel-indicators new"> <li data-target="#quote-carousel" data-slide-to="0" class="active"></li> <l

我正在用php将静态html站点转换为动态站点,我有一个
,其中
  • 是静态添加的,即用户推荐,当添加新推荐时,我需要列表自动递增。i、 e如果有一个证明,则项目符号应为,对于2,项目符号为2,依此类推。我的html代码是:

    <ol class="carousel-indicators new">
        <li data-target="#quote-carousel" data-slide-to="0" class="active"></li>
        <li data-target="#quote-carousel" data-slide-to="1"></li>
        <li data-target="#quote-carousel" data-slide-to="2"></li>
    </ol>
    
    
    
    欢迎你的问题是什么?我们可以看到你已经拥有的代码吗?@SadaKhan不要在评论中发布你的代码,将其添加为对你的问题的编辑!列表现在是动态的。我已经用代码编辑了你的帖子。这不是你问题的答案。
    <div class="carousel slide" data-ride="carousel" id="quote-carousel">
                <!-- Carousel Slides / Quotes -->
                    <div class="carousel-inner">
                        <?php 
    
                            $args = array(
                                'post_type' => 'testimonials_post'                  
                            );
                            $the_query = new WP_Query( $args );
    
                            if ( $the_query->have_posts() ) {
                                $i = 1;     
                                $bullets="";        
                                while ( $the_query->have_posts() ) {
                                    $the_query->the_post();
                                    $post_id = get_the_ID();
                                    $post_title = get_the_title($post_id);
                                    $post_content = get_the_content($post_id);
                                    $featured_img_url = get_the_post_thumbnail_url($post_id, 'medium');
                    ?>
                        <div class="item <?php echo $the_query->current_post >= 1 ? '' : 'active'; ?> text-center">
                            <div class="row">
                                <div class="col-sm-12">
                                    <img src="<?php echo $featured_img_url; ?>" class="img-o">
                                    <?php echo $post_content; ?>
                                    <small><strong><?php echo $post_title; ?></strong></small>
                                </div>
                            </div>
                        </div>
                        <?php
                        $activeclass="";
                        if($i==1){
                            $activeclass='class="active"';
                        }
                        $bullets.='<li data-target="#quote-carousel" data-slide-to="'.($i-1).'" '.$activeclass.'></li>';
                        $i++;
                            }
    
    
                            }
    
                            wp_reset_query();
    
                        ?>
                    </div>
                    <!-- Bottom Carousel Indicators -->
                    <ol class="carousel-indicators new">
                        <?php
                        echo $bullets;
                        ?>
    
                    </ol>
                </div>
    
    <div class="carousel slide" data-ride="carousel" id="quote-carousel">
                <!-- Carousel Slides / Quotes -->
                    <div class="carousel-inner">
                        <?php 
    
                            $args = array(
                                'post_type' => 'testimonials_post'                  
                            );
                            $the_query = new WP_Query( $args );
    
                            if ( $the_query->have_posts() ) {
                                $i = 1;     
                                $bullets="";        
                                while ( $the_query->have_posts() ) {
                                    $the_query->the_post();
                                    $post_id = get_the_ID();
                                    $post_title = get_the_title($post_id);
                                    $post_content = get_the_content($post_id);
                                    $featured_img_url = get_the_post_thumbnail_url($post_id, 'medium');
                    ?>
                        <div class="item <?php echo $the_query->current_post >= 1 ? '' : 'active'; ?> text-center">
                            <div class="row">
                                <div class="col-sm-12">
                                    <img src="<?php echo $featured_img_url; ?>" class="img-o">
                                    <?php echo $post_content; ?>
                                    <small><strong><?php echo $post_title; ?></strong></small>
                                </div>
                            </div>
                        </div>
                        <?php
                        $activeclass="";
                        if($i==1){
                            $activeclass='class="active"';
                        }
                        $bullets.='<li data-target="#quote-carousel" data-slide-to="'.($i-1).'" '.$activeclass.'></li>';
                        $i++;
                            }
    
    
                            }
    
                            wp_reset_query();
    
                        ?>
                    </div>
                    <!-- Bottom Carousel Indicators -->
                    <ol class="carousel-indicators new">
                        <?php
                        echo $bullets;
                        ?>
    
                    </ol>
                </div>