• Resolved girdy74

    (@girdy74)


    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)
  • ..I’m back and I think I have my query programmed incorrectly. I don’t think it’s pulling correctly from the start….investigating now!

    ..back again. I figured out my issue above the MORE button. I know have all posts within the category permalink. But, after the MORE button is clicked, I get all sorts of posts from different category and not just of my “Move” category posts.

    So not sure how to pass on to the LOAD MORE shortcode that it’s posts from the category page selected. 🙂

    Thanks!

    Plugin Author dcooney

    (@dcooney)

    Hi @girdy74,
    Can you send me a link to this issue?

    Plugin Author dcooney

    (@dcooney)

    Oh wow! I hadn’t seen that 😉 that helps a TON!

    Is there a way I can send the link in a pm?

    I ask because, that did the trick, but the results are fairly slow to load. I’m wondering if this is because this is a staging site at Kinsta and not cached. Does this plugin work well with caching? And, would that help the load time do you think?

    Everything is working great! Forget my “slow loading” comment. I think it was just the timing and my network was slow because today it’s fine.

    I appreciate the link because that fixed everything. This plugin is awesome, thank you so much!

Viewing 7 replies - 1 through 7 (of 7 total)
  • You must be logged in to reply to this topic.