Advertisement
Guest User

Untitled

a guest
Oct 8th, 2012
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.38 KB | None | 0 0
  1. //TRYING TO GET PAGINATION WORKING
  2. $paged = ( get_query_var( 'paged' ) ) ? get_query_var( 'paged' ) : 1;
  3.  
  4. //GETTING THE PARENT CATEGORY HERE AND CHILD CATEGORIES
  5. $allcats = get_categories(array('child_of' => get_query_var('cat'), 'number' => 3,'order'=> 'asc', 'paged' => $paged));
  6. foreach ($allcats as $cat) :   
  7. $args = array(
  8.  'category__in' => array($cat->term_id),
  9. );
  10.  
  11. $customInCatQuery = new WP_Query($args);
  12.  
  13. if ($customInCatQuery->have_posts()) :
  14. echo '<div class="menupageContent">';
  15.     //THIS CODE GETS THE IMAGE ATTACHED TO THE PARENT CATEGORY USING A PLUGIN
  16.         $terms = apply_filters( 'taxonomy-images-get-terms', '' );
  17.         if ( ! empty( $terms ) ) {
  18.         foreach( (array) $terms as $term ) {
  19.                 if($term->term_id == $cat->term_id) {
  20.                   echo wp_get_attachment_image( $term->image_id, 'menu' );
  21.                 }
  22.         }
  23.         }
  24. //LIST THE TITLE OF THE CHILD CATEGORY
  25. echo '<h3>'.$cat->name.'</h3>';
  26. echo '<ul>';    
  27. while ($customInCatQuery->have_posts()) : $customInCatQuery->the_post(); ?>
  28. //LIST THE TITLES OF THE POSTS MADE TO EACH TITLE CATEGORY
  29. <li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li>
  30.  
  31.  <?php
  32.  endwhile;
  33.  echo '</ul></div><!--end menupageContent-->';
  34.  
  35.  ?>
  36.  
  37.  <?php else :
  38.  echo 'No post published in:'.$cat->name;                
  39.  endif;
  40.  wp_reset_query();
  41.  endforeach;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement