在我的索引页面中,有两个滑块,一个运行良好,但第二个滑块存在一些问题。
第一个
<?php
global $post;
$i=0;
$args = array(\'post_per_page\' => -1, \'post_type\' => \'slider-items\', \'page\' => $paged, \'order\' => \'ASC\');
$myposts = get_posts($args);
foreach( $myposts as $post ) : setup_postdata($post);
$large_image_url = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), \'slider-items\');
$i++;
?>
<!-- Slider Item -->
<div class="owl-item main_slider_item">
<div class="main_slider_item_bg" style="background-image:url(<?php echo $large_image_url[0]; ?>)"></div>
<div class="main_slider_shapes"><img src="<?php echo get_template_directory_uri() ?>/images/main_slider_shapes.png" alt="" style="width: 100% !important;"></div>
<div class="container">
<div class="row">
<div class="col slider_content_col">
<div class="main_slider_content">
<h2></h2>
<h2><?php the_content(); ?></h2>
<div class="button discover_button">
<a href="#" class="d-flex flex-row align-items-center justify-content-center">discover<img src="<?php echo get_template_directory_uri() ?>/images/arrow_right.svg" alt=""></a>
</div>
</div>
</div>
</div>
</div>
</div>
<?php
endforeach;
?>
第二个
<?php
global $small_post;
$x=0;
$small_args = array(\'post_per_page\' => -1, \'post_type\' => \'bottom-slider-items\', \'page\' => $small_paged);
$small_myposts = get_posts($small_args);
foreach( $small_myposts as $small_post ) : setup_postdata($small_post);
$small_image_url = wp_get_attachment_image_src( get_post_thumbnail_id($small_post->ID), \'bottom-slider-items\');
$x++;
?>
<div class="owl-item testimonials_item d-flex flex-column align-items-center justify-content-center text-center">
<div class="testimonials_content">
<div class="test_user_pic" style="background-image:url(<?php echo $small_image_url[0]; ?>)"></div>
<div class="test_name"><?php echo get_the_title(); ?></div>
<div class="test_title">Company CEO</div>
<div class="test_quote">"</div>
<p><?php the_content(); ?></p>
</div>
</div>
<?php
endforeach;
?>
当我打电话时
get_the_title()
它显示了第一个循环的标题。我在第一个和第二个循环中添加了三个滑块帖子,显示了最后一个的标题。请帮忙。