Guest User

Untitled

a guest
Nov 24th, 2017
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.41 KB | None | 0 0
  1. wp_list_categories('use_desc_for_title=1');
  2.  
  3. <ul id="category_list">
  4. <li><a href="#" title="3">Category C</a></li>
  5. <li><a href="#" title="1">Category A</a></li>
  6. <li><a href="#" title="2">Category B</a></li>
  7. </ul>
  8.  
  9. $( document ).ready(
  10. function() {
  11. sort_list_recursive( $( '#category_list' ) );
  12. }
  13. );
  14.  
  15. function sort_list_recursive( parent ) {
  16. var lst = parent.children( 'li' );
  17. lst.sort(
  18. function( a, b ) {
  19. var _a = a.getElementsByTagName( 'a' )[0].title;
  20. var _b = b.getElementsByTagName( 'a' )[0].title;
  21. return _a > _b ? 1 : -1;
  22. }
  23. ).appendTo( parent );
  24. lst.each( function() {
  25. $( this ).children( 'ul' ).each( function() {
  26. sort_list_recursive( $( this ) );
  27. });
  28. });
  29. }
  30.  
  31. wp_list_categories('orderby=name');
  32.  
  33. $terms = get_terms('my_taxonomy', 'hide_empty=0');
  34. foreach ( $terms as $term ) {
  35. ${$term->slug} = get_term_by('slug', $term->slug, 'product_cat');
  36. ${$term->slug.'_array'} = (array)${$term->slug};
  37. ${$term->slug.'_array_id'} =${$term->slug.'_array'}['term_id'];
  38. };
  39.  
  40. $args = array(
  41. 'taxonomy' => 'my_taxonomy',
  42. 'orderby' => 'name',
  43. 'show_count' => true,
  44. 'pad_counts' => false,
  45. 'hierarchical' => true,
  46. 'title_li' => '',
  47. 'hide_empty' => 0,
  48. 'show_option_all' => 'Show all',
  49. 'exclude' => array( $term1_array_id, $term2_array_id )
  50. );
  51.  
  52. $args_1 = array(
  53. 'taxonomy' => 'my_taxonomy',
  54. 'orderby' => 'name',
  55. 'show_count' => true,
  56. 'pad_counts' => false,
  57. 'hierarchical' => true,
  58. 'title_li' => '',
  59. 'hide_empty' => 0,
  60. 'exclude' => array( $term3_array_id, $term4_array_id, $term1_array_id )
  61. );
  62.  
  63. $args_2 = array(
  64. 'taxonomy' => 'my_taxonomy',
  65. 'orderby' => 'name',
  66. 'show_count' => true,
  67. 'pad_counts' => false,
  68. 'hierarchical' => true,
  69. 'title_li' => '',
  70. 'hide_empty' => 0,
  71. 'exclude' => array( $term1_array_id, $term4_array_id, $term5_array_id )
  72. );
  73.  
  74. <ul>
  75. <?php wp_list_categories( $args ); ?>
  76. <?php wp_list_categories( $args_1 ); ?>
  77. <?php wp_list_categories( $args_2 ); ?>
  78. </ul>
  79.  
  80. $categories = get_categories( array(
  81. 'orderby' => 'description',
  82. 'order' => 'ASC'
  83. ) );
Add Comment
Please, Sign In to add comment