Category Results
-
This plugin is incredible! ?? Thank you!
I’m struggling with how to have the Ajax Load More only incorporate the category of the current category page. For example, my query that lists out the first 12 posts is as follows (archive.php):
<?php $category = get_the_category($post->ID); $category = $category[0]->cat_ID; $args = array( 'posts_per_page' => 12, 'offset' => 0, 'category__in' => array($category), 'post_type' => 'post', 'post_status'=>'publish', 'orderby' => 'post_date', 'order'=>'DESC' ); $custom_query = new WP_Query($args); while($custom_query->have_posts()) : $custom_query->the_post(); ?> <div class="post-box flexing"> <div class="post-image"> <?php if ( has_post_thumbnail() ) { echo '<div class="featured">'; echo '<a href="' . get_permalink() . '">'; the_post_thumbnail('post-thumbnail', array( 'class'=> "size-full")); echo '</a>'; echo '</div>'; } ?> </div><!--.post-image--> <div class="post-title"> <a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>"><?php the_title(); ?></a> <?php the_excerpt(); ?> <div class="cat-tags"> <?php corvidstudio_entry_footer(); ?> </div><!--.cat-tags--> </div><!--.post-title--> </div><!--.post-box.flexing--> <?php endwhile; ?> <?php wp_reset_postdata(); // reset the query ?>
My shortcode is: [ajax_load_more container_type=”div” css_classes=”.post-archive” post_type=”post” posts_per_page=”6″ pause=”true” scroll=”false” button_label=”More” css_classes=”flexbox”]
When I click the “more” button, I get all other categories within that are not in my main query. Can you help guide me in what I’m doing wrong? I really appreciate any recommendations to solve this.
Viewing 7 replies - 1 through 7 (of 7 total)
Viewing 7 replies - 1 through 7 (of 7 total)
- The topic ‘Category Results’ is closed to new replies.