Advertisement
bongzilla

Untitled

Nov 10th, 2021
920
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.62 KB | None | 0 0
  1. <?php
  2. $cats = get_categories();
  3.  
  4. foreach ($cats as $cat) {
  5. $args = array(
  6. 'post_type' => 'support',
  7. 'tax_query' => array(
  8.     array(
  9.         'taxonomy' => 'category',
  10.         'field'    => 'term_id',
  11.         'terms'    => $cat->cat_ID,
  12.         ),
  13.     ),
  14. );
  15. $query = new WP_Query($args);
  16.  
  17. if ( $query->have_posts() ): ?>
  18.     <p><?php echo $cat->cat_name ; ?></p> <?
  19.  
  20.    while($query -> have_posts()) : $query -> the_post(); ?>
  21.       <h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
  22.       <p><?php the_content(); ?></p> <?php
  23.    endwhile;
  24. endif;
  25.  
  26. // Added this now
  27. wp_reset_query() ;
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement