linccce

my cat lister

Jul 15th, 2015
216
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.54 KB | None | 0 0
  1. //Custom categories listing Walker
  2. class Post_Categories_Grid extends Walker_Category {
  3.  
  4.     // Displays start of a level. E.g '<ul>'
  5.     // @see Walker::start_lvl()
  6.     public function start_lvl(&$output, $depth=0, $args=array()) {
  7.         $output .= "\n<ul class='row'>\n";
  8.     }
  9.  
  10.     // Displays end of a level. E.g '</ul>'
  11.     // @see Walker::end_lvl()
  12.     public function end_lvl(&$output, $depth=0, $args=array()) {
  13.         $output .= "</ul>\n";
  14.     }
  15.  
  16.     // Displays start of an element. E.g '<li> Item Name'
  17.     // @see Walker::start_el()
  18.     public function start_el(&$output, $category, $depth=0, $args=array()) {
  19.         $link = esc_url( get_term_link( $category ) );
  20.         $image = "<img src='".cfi_featured_image_url( array( 'size' => 'medium', 'cat_id'=>$category->term_id ) )."' />";
  21.         $output .= "<li class='product col-xs-6 col-md-4'><a href='$link' >$image<h3>".strtoupper(esc_attr($category->name));
  22.     }
  23.  
  24.     // Displays end of an element. E.g '</li>'
  25.     // @see Walker::end_el()
  26.     public function end_el(&$output, $category, $depth=0, $args=array()) {
  27.         $output .= "<mark class='count'>(".esc_attr($category->count).")</mark></h3></a></li>\n";
  28.     }
  29. }
  30.  
  31.  
  32. function estlita_category_list($args = array()){
  33.     $args = array(
  34.         'show_count'=>true,
  35.         'exclude'=>'1',
  36.         'depth'=>1,
  37.         'use_desc_for_title'=>true,
  38.         'style'=>'',
  39.         'walker'=> new Post_Categories_Grid()
  40.     );
  41.     echo "<ul class='products row'>";
  42.     wp_list_categories($args);
  43.     echo "</ul>";
  44. }
Advertisement
Add Comment
Please, Sign In to add comment