Advertisement
bennyp

Untitled

Apr 9th, 2012
35
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2.  
  3. // Shortcode for displaying children of a category in a horizontal list
  4.  
  5. function horizontal_category_func( $parent, $content = null ) {
  6. // debug to check if function is being called
  7.  //exit("I've been hit!");
  8.     extract(shortcode_atts(array(
  9.         "parent" => 'ID'
  10.     ), $parent));
  11.    
  12.     $slug = $parent->slug;
  13.     $cat_name = get_the_category_by_ID( $parent );
  14.     $cat_title = "<h3><a href=\"category/$slug\">$cat_name</a></h3>";
  15.     echo=0;
  16.     $cat_list = wp_list_categories( "child_of=$parent&show_count=1&title_li=$cat_title" );
  17.    
  18.     return $cat_list;
  19. }
  20.  
  21. add_shortcode( 'horizontal_category', 'horizontal_category_func' );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement