У меня есть WordPress сайт. И я реализовал сову карусели. Всего в цикле 17 предметов. Но карусель показывает 10. Если я <pre></pre>
внутри цикла, то все 17 шоу. Что я должен делать?
У меня есть этот скрипт в конце моей страницы
<script type="text/javascript">
$(document).ready(function() {
$('#myCarousel1.carousel').owlCarousel({
items:1,
loop:true,
margin:0,
autoHeight:true
});
});
</script>
И МОЙ HTML КОД
<!-- Portfolio Section Starts -->
<?php $posts = get_posts(array(
'post_type' => 'portfolio_post',
'post_status' => 'publish',
'posts_per_page' => 0,
'fields' => 'ids'
)
);
// echo '<pre>';
// print_r($posts);
// echo '</pre>';
foreach($posts as $p){
$portfolio_color_picker1 = get_post_meta($p,"portfolio-color_picker_1",true);
$portfolio_color_picker2 = get_post_meta($p,"portfolio-color_picker-2",true);
$contact_color_picker1 = get_post_meta($p,"contact-color_picker-1",true);
$contact_color_picker2 = get_post_meta($p,"portfolio-color_picker-2",true);
$google_play_store_label = get_post_meta($p,"google_play_store_label",true);
$google_play_store_url = get_post_meta($p,"google_play_store_url",true);
$apple_store_label = get_post_meta($p,"apple_store_label",true);
$apple_store_url = get_post_meta($p,"apple_store_url",true);
$google_sub_title = get_post_meta($p,"google_sub_title",true);//echo $name = get_post_meta($p,"we-color_picker-1",true);
//do whatever you want with it
}
?>
<?php $background = of_get_option('business_portfolio_colorpicker', true ) ;
$img = $background['image']; ?>
<section id="portfolio" class="portfolio-section" style="background:<?php if( $background['color'] ) echo $background['color']; else if($background['image']) echo 'url('.$img.')'; ?>">
<div class="container">
<div class="row">
<div class="col-lg-12 portfolio-inner"><?php
$backgroundtitle = of_get_option('business_portfolio_title_colorpicker', true );
$backgroundsubtitle = of_get_option('business_portfolio_subtitle_colorpicker', true );
?>
<h1 style="color : <?php echo $backgroundtitle; ?>"><?php echo of_get_option('business_portfolio_title',true); ?></h1>
<h2 style="color :<?php echo $backgroundsubtitle; ?> "><?php echo of_get_option('business_portfolio_subtitle',true); ?></h2>
<section id="myCarousel1" class="carousel slide">
<?php $content = of_get_option('business_portfolio_content_colorpicker', true );
?> <style type="text/css">
.vk_content p{
color : <?php echo $content.' !important'; ?>;
}
</style>
<div class="carousel-inner">
<?php $loop = new WP_Query( array( 'post_type' => 'portfolio_post', 'post_status'=>'publish','order'=> 'ASC', ) );
while ( $loop->have_posts() ) : $loop->the_post();
?>
<div class="items-portfolio">
<div class="text-center bs-ft">
<a href="<?php the_permalink(); ?>"> <?php echo the_post_thumbnail('full'); ?> </a>
</div>
<div class="col-lg-12 technical-features">
<?php $content_title = of_get_option('business_portfolio_content_title_colorpicker', true );
$content_subtitle = of_get_option('business_portfolio_content_subtitle_colorpicker', true );
?>
<h3 style="color : <?php echo $content_title; ?>"><?php the_title(); ?></h3>
<!--<h4>iOS - 7Objectivle - CXcodePush - Notification Integration - Social Media Integration - oAuth iOS 7 Maps
<br>In App Purchase Integration</h4>-->
<h4 style="color : <?php echo $content_subtitle; ?>"><?php echo get_post_meta(get_the_ID(), "_tech_feature", true); ?></h4><div class="vk_content"><?php the_content();?></div>
<div class="button-container">
<a href="<?php echo get_post_meta(get_the_ID(), "_google_play_store", true); ?>">
<button type="button" class="btn btn-primary"><img src="<?php echo esc_url( get_template_directory_uri() ); ?>/images/button-bg-1.png" alt="">play store</button>
</a>
<a href="<?php echo get_post_meta(get_the_ID(), "_apple_store", true);?>">
<button type="button" class="btn btn-primary"><img src="<?php echo esc_url( get_template_directory_uri() ); ?>/images/button-bg-2.png" alt="">apple store</button>
</a>
</div>
</div>
</div>
<?php endwhile; wp_reset_query();?>
</div>
</section>
</div>
</div>
</div>
</section>
<!-- ======= End Slider Section ======== -->
</div>
</div>
</div>
</section>
<!-- End Portfolio Section -->
Вы пытались добавить 'posts_per_page' => -1
на ваш запрос params в wp_query?
Так это будет выглядеть так:
<?php $loop = new WP_Query( array( 'post_type' => 'portfolio_post', 'post_status'=>'publish','order'=> 'ASC','posts_per_page' => -1) );
Обновить
В качестве альтернативы, вы можете установить для nopaging значение true.
'nopaging' => true
https://codex.wordpress.org/Class_Reference/WP_Query#Pagination_Parameters
Других решений пока нет …