我有一个wordpress网站。我已经实施了猫头鹰。循环中共有17项。但是carousal显示10.如果我在循环中<pre></pre>
,那么所有17个显示。我该怎么办?
我的页面末尾有这个脚本
<script type="text/javascript">
$(document).ready(function() {
$('#myCarousel1.carousel').owlCarousel({
items:1,
loop:true,
margin:0,
autoHeight:true
});
});
</script>
AND MY 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 -->
答案 0 :(得分:0)
您是否尝试将'posts_per_page' => -1
添加到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