Guest User

Untitled

a guest
Jan 23rd, 2018
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.92 KB | None | 0 0
  1. <?php
  2.             // set up taxonomies
  3.             $tax_one = 'service_categories';
  4.             $post_type = 'services';
  5.            
  6.             $categories = get_categories( array(
  7.             'post_type'                     => $post_type,
  8.             'orderby'                  => 'name',
  9.             'order'                    => 'ASC',
  10.             'hide_empty'               => 1,
  11.             'hierarchical'             => 1,
  12.             'taxonomy'                 => $tax_one ));
  13.            
  14.             foreach ( $categories as $category ) : // list all categories
  15.                    
  16.                 echo '<h2><a href="'.get_term_link( $category->slug, $tax_one ).'">'.$category->name.'</a></h2>'?>
  17.            
  18.                 <?php
  19.                
  20.                 $args['tax_query'] = array(
  21.                     array(
  22.                         'taxonomy' => $tax_one,
  23.                         'terms' => array($category->slug),
  24.                         'field' => 'slug'
  25.                     ),
  26.                 );
  27.                
  28.                 $loop = new WP_Query( $args );
  29.                 if ( $loop->have_posts() ) :
  30.                
  31.                 ?>
  32.                
  33.                     ...loop stuff here
  34.                
  35.                 <?php endif; ?>
  36.                
  37.             <?php endforeach; ?>
Add Comment
Please, Sign In to add comment