Guest User

Untitled

a guest
Jul 23rd, 2018
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.74 KB | None | 0 0
  1. // Shortcode for displaying children of a category in a horizontal list
  2.  
  3. function horizontal_category_func( $parent ) {
  4.        
  5.     extract(shortcode_atts(array(
  6.         "parent" => 'ID'
  7.     ), $parent));
  8.    
  9.     $slug = $parent->slug;
  10.     $cat_name = get_the_category_by_ID( $parent );
  11.     $cat_title = "<h3><a href=\"category/$slug\">$cat_name</a></h3>";
  12.     $cat_list = wp_list_categories( "child_of=$parent&show_count=1&title_li=$cat_title" );
  13.    
  14.     return $cat_list;
  15. }
  16.  
  17. add_shortcode( 'horizontal_category', 'horizontal_category_func' );
  18.  
  19. //PAGE CONTENT:
  20. //<div id="horizontalcategories">
  21. //[horizontal_category parent="22"]
  22. //[divider style="solid"]
  23. //[horizontal_category parent="278"]
  24. //[divider style="solid"]
  25. //[horizontal_category parent="287"]
  26. //</div>
Add Comment
Please, Sign In to add comment