Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //TRYING TO GET PAGINATION WORKING
- $paged = ( get_query_var( 'paged' ) ) ? get_query_var( 'paged' ) : 1;
- //GETTING THE PARENT CATEGORY HERE AND CHILD CATEGORIES
- $allcats = get_categories(array('child_of' => get_query_var('cat'), 'number' => 3,'order'=> 'asc', 'paged' => $paged));
- foreach ($allcats as $cat) :
- $args = array(
- 'category__in' => array($cat->term_id),
- );
- $customInCatQuery = new WP_Query($args);
- if ($customInCatQuery->have_posts()) :
- echo '<div class="menupageContent">';
- //THIS CODE GETS THE IMAGE ATTACHED TO THE PARENT CATEGORY USING A PLUGIN
- $terms = apply_filters( 'taxonomy-images-get-terms', '' );
- if ( ! empty( $terms ) ) {
- foreach( (array) $terms as $term ) {
- if($term->term_id == $cat->term_id) {
- echo wp_get_attachment_image( $term->image_id, 'menu' );
- }
- }
- }
- //LIST THE TITLE OF THE CHILD CATEGORY
- echo '<h3>'.$cat->name.'</h3>';
- echo '<ul>';
- while ($customInCatQuery->have_posts()) : $customInCatQuery->the_post(); ?>
- //LIST THE TITLES OF THE POSTS MADE TO EACH TITLE CATEGORY
- <li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li>
- <?php
- endwhile;
- echo '</ul></div><!--end menupageContent-->';
- ?>
- <?php else :
- echo 'No post published in:'.$cat->name;
- endif;
- wp_reset_query();
- endforeach;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement