本文整理汇总了PHP中WP_Query::found_posts方法的典型用法代码示例。如果您正苦于以下问题:PHP WP_Query::found_posts方法的具体用法?PHP WP_Query::found_posts怎么用?PHP WP_Query::found_posts使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WP_Query
的用法示例。
在下文中一共展示了WP_Query::found_posts方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: rc_woocommerce_recently_viewed_products
function rc_woocommerce_recently_viewed_products()
{
// Get shortcode parameters
$per_page = 15;
global $woocommerce;
$viewed_products = !empty($_COOKIE['woocommerce_recently_viewed']) ? (array) explode('|', $_COOKIE['woocommerce_recently_viewed']) : array();
$viewed_products = array_filter(array_map('absint', $viewed_products));
if (empty($viewed_products)) {
return '';
}
if (!isset($per_page) ? $number = 5 : ($number = $per_page)) {
$query_args = array('posts_per_page' => $number, 'no_found_rows' => 1, 'post_status' => 'publish', 'post_type' => 'product', 'post__in' => $viewed_products, 'orderby' => 'rand');
}
$query_args['meta_query'] = array();
$query_args['meta_query'][] = $woocommerce->query->stock_status_meta_query();
$r = new WP_Query($query_args);
if ($r->have_posts()) {
if ($r->found_posts() > 5) {
?>
<?php
}
// Start the loop
while ($r->have_posts()) {
$r->the_post();
global $product;
?>
<div class="swiper-slide col-xs-4 col-sm-6 col-md-4">
<a title="<?php
the_title();
?>
" href="<?php
the_permalink();
?>
">
<img class="item-image" src="<?php
echo wp_get_attachment_url(get_post_thumbnail_id(get_the_ID()));
?>
">
<!-- --><?php
//the_post_thumbnail(array(138,74),array('class'=> 'item-image'));
?>
<div class="item-info"><?php
the_title();
?>
</div>
</a>
</div>
<?php
}
}
}
示例2: rc_woocommerce_recently_viewed_products
function rc_woocommerce_recently_viewed_products()
{
// Get shortcode parameters
$per_page = 15;
global $woocommerce;
$viewed_products = !empty($_COOKIE['woocommerce_recently_viewed']) ? (array) explode('|', $_COOKIE['woocommerce_recently_viewed']) : array();
$viewed_products = array_filter(array_map('absint', $viewed_products));
if (empty($viewed_products)) {
return '';
}
if (!isset($per_page) ? $number = 5 : ($number = $per_page)) {
$query_args = array('posts_per_page' => $number, 'no_found_rows' => 1, 'post_status' => 'publish', 'post_type' => 'product', 'post__in' => $viewed_products, 'orderby' => 'rand');
}
$query_args['meta_query'] = array();
$query_args['meta_query'][] = $woocommerce->query->stock_status_meta_query();
$r = new WP_Query($query_args);
if ($r->have_posts()) {
if ($r->found_posts() > 5) {
?>
<script type="text/javascript">
$(document).ready(function(){
$('.last-view-items').bxSlider({
controls:true,
auto:false,
pager:false,
minSlides:5,
maxSlides:15,
slideMargin: 0,
slideWidth:184,
nextText:'<i class="fa fa-caret-right"></i>',
prevText:'<i class="fa fa-caret-left"></i>',
nextSelector:'.controls-view',
prevSelector:'.controls-view'
});
});
</script>
<?php
}
echo '<ul class="last-view-items clearfix">';
// Start the loop
while ($r->have_posts()) {
$r->the_post();
global $product;
?>
<li class="clearfix">
<a title="<?php
the_title();
?>
" href="<?php
the_permalink();
?>
">
<?php
the_post_thumbnail(array(111, 73));
?>
<p class="title"><?php
the_title();
?>
</p>
</a>
</li>
<?php
}
echo '</ul>';
}
}