2016-02-04 59 views
0

我创建了一个自定义后类型,注册它,以及创建和注册相关的自定义分类。我需要以某种分页类别页面,如,“你在这个自定义分类观察1-10 15职位”,然后在底部的链接,这些下一页。显示在自定义后类型分类Ÿ职位的X WordPress的

我的回路的工作很好,并低于:

<div class="simple-product-listing archive-box"> 

<?php while (have_posts()) : the_post(); ?> 

<li> 

    <div <?php post_class($classes); ?>> 

     <a title="<?php the_title() ?>" href="<?php the_permalink(); ?>" data-toggle="tooltip"> 
      <div class="row catalog"> 
       <div class="col-md-6 col-md-push-6 arrow"> 

        <?php if ((function_exists('has_post_thumbnail')) && (has_post_thumbnail())) { 
         $thumb = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID), 'dnf-cat'); 
         $url = $thumb['0']; 
        ?> 

        <div class="the-prod-image" style="background-image: url(<?=$url?>);"></div> 

        <?php } else { ?> 
        <div class="the-image-div" style="background-image: url(<?php bloginfo('template_directory'); ?>/images/default.svg);"></div> 
        <?php } ?> 

       </div> 

       <div class="col-md-6 col-md-pull-6 arrow"> 
        <h3 class="post-box-title"><?php the_title(); ?></h3> 

        <div class="entry"> 
         <i class="blog-title-border"></i> 
         <?php the_excerpt() ?> 
         <div class="btn btn-default btn-sm active text-uppercase" role="button" title="<?php the_title() ?>">Read More &raquo;</div> 
        </div> 
       </div> 

       <div class="clear"></div> 
      </div> 
     </a> 

    </div> 
</li> 

<?php endwhile;?> 

</div> 

所有我已经成功地在分页显示方面迄今弄清楚的是:

<?php 
    $pagenum = $query->query_vars['paged'] < 1 ? 1 : $query->query_vars['paged']; 
    $first = (($pagenum - 1) * $query->query_vars['posts_per_page']) + 1; 
    $last = $first + $query->post_count - 0; 
    echo '<p class="results-count">Showing ' . $first . ' of ' . $last . ' products in this category</p>'; 
?> 

但是这并未” T显示“的”数量大于1,并且不解决,我想在页面底部的分页项目。

回答

0

后我发现相当多的搜索和试验&错误的解决方案......

<?php 
    // Number of products in category 
    $pagenum = $query->query_vars['paged'] < 1 ? 1 : $query->query_vars['paged']; 
    $first = (($pagenum - 1) * $query->query_vars['posts_per_page']) + 1; 
    $term = get_term_by('slug', get_query_var('term'), get_query_var('taxonomy')); 

    echo '<p class="results-count">Showing ' . $first . ' of ' .count($myposts = get_posts($args)). ' products in this category</p>'; 
?> 
相关问题