当前位置: 首页>>代码示例>>PHP>>正文


PHP WP_Query::found_posts方法代码示例

本文整理汇总了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 
        }
    }
}
开发者ID:Nguyenkain,项目名称:hanghieusales,代码行数:52,代码来源:woocommerce.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>';
    }
}
开发者ID:Nguyenkain,项目名称:hanghieusales,代码行数:66,代码来源:woocommerce.php


注:本文中的WP_Query::found_posts方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。