Guest User

Untitled

a guest
Feb 23rd, 2018
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.12 KB | None | 0 0
  1. <?php
  2. $paged = ( get_query_var( 'paged' ) ) ? get_query_var('paged') : 1;
  3. $cat_id = 42;
  4. $child_categories=get_categories(
  5. array( 'parent' => $cat_id )
  6. );
  7.  
  8. foreach ( $child_categories as $child ) { ?>
  9. <!-- loop through child categories and make columns -->
  10. <div class="col-sm-4">
  11.  
  12. <!-- category title -->
  13. <?php
  14. $string = $child ->cat_name;
  15. $className = str_replace(' ', '', $string);
  16. ?>
  17. <h2 class="cat-icon <?php echo $className; ?>"><?php echo $child ->cat_name; ?></h2>
  18.  
  19. <!-- query -->
  20. <?php $args = array( 'category_name' => $child->cat_name, 'posts_per_page' => -1, 'paged' => $paged, 'orderby' => 'title', 'order' => 'ASC' );
  21. $loop = new WP_Query( $args ); ?>
  22.  
  23. <!-- loop to create buttons -->
  24. <?php while ( $loop->have_posts() ) : $loop->the_post(); ?>
  25. <?php get_template_part("home", "service-button"); ?>
  26. <?php endwhile; ?>
  27.  
  28.  
  29. </div>
  30.  
  31. <?php } ?><!-- end foreach loop -->
Add Comment
Please, Sign In to add comment