我想添加分类的分页列表

时间:2017-02-02 作者:user3895178
<?php
$paged = (get_query_var(\'paged\')) ? get_query_var(\'paged\') : 1;
    $posts_per_page = 5;
    $offset = ($posts_per_page * $paged) - 12 ;

 $args = array(
 \'orderby\' => \'id\',
 \'hide_empty\'=> 0,
\'number\' => $posts_per_page,
\'offset\' => $offset,
 \'parent\' => 0, //Child From Boxes Category 

);
$categories = get_categories($args);
 foreach ($categories as $cat) {
   echo \'<li style="">\';
 echo $cat->name;
     echo \'<br />\';


    echo \'</li>\';
 }
?>
1 个回复
SO网友:user3895178
     <?php    
    $args = array(
   \'parent\' => 0,
   \'hide_empty\' => 0
 );

$categories = get_categories( $args );
echo $cat =  ceil(count( $categories )/5);    
 ?>
 <?php
  $j=0;
 $paged = (get_query_var(\'paged\')) ? get_query_var(\'paged\') : 1;
  $posts_per_page = 5;
$offset = ($posts_per_page * $paged) - 5 ;
$args = array(
\'orderby\' => \'name\',
\'parent\' => 0,
\'hide_empty\'         => 0,
\'number\' => $posts_per_page,
\'offset\' => $offset,
\'posts_per_page\' => 5,
\'paged\' => $paged

//\'exclude\'            => \'1,3,24,9\'
);
$categories = get_categories( $args );
foreach ( $categories as $category ) {
$j++;
 //echo \'<a href="\' . get_category_link( $category->term_id ) . \'">\' .       $category->name . \'</a><br/>\';
 $catname = $category->name;
 $catttid = $category->term_taxonomy_id;
  //}
   ?>

<div class="row"><h3 class="cat-title"><?php echo $catname; ?></h3><hr  class="space" /></div>
  <?php } ?>
  </div></div>
   <!-- #main -->
  </div><!-- #primary -->
  <?php
  $big = 999999999; // need an unlikely integer
    echo \'<div class="paginate-links">\';
  echo paginate_links( array(
  \'base\' => str_replace( $big, \'%#%\', esc_url( get_pagenum_link( $big ) ) ),
  \'format\' => \'?paged=%#%\',
  \'prev_text\' => __(\'<<\'),
  \'next_text\' => __(\'>>\'),
  \'current\' => max( 1, get_query_var(\'paged\') ),
  \'total\' => $cat
     ) );
echo \'</div>\';
  ?>

相关推荐

Ajax Filtering Pagination

我知道这是一个常见的问题,但我找不到解决办法。我在用户点击复选框时进行了ajax过滤。在用户单击分页之前,一切都正常。当然,我们现在使用的是管理ajax。php页面和分页链接不工作。这是代码。HTML复选框:<input type=\"checkbox\" id=\"telegram_chk\" checked> <input type=\"checkbox\" id=\"twitter_chk\" checked> <input type=\"checkbo