• I have the button working. But when you select a blog category, it’s still loading ALL posts, not just the posts from that category.

    I’m using the following template shortcode outside the loop, at the end of the query.

    how do I configure this so that it only loads the posts from the category that is selected. This would be for the archive.php and category.php templates.

    echo do_shortcode('[ajax_load_more post__not_in="'.$post__not_in.'" container_type="div" post_type="post" posts_per_page="24" pause="true" transition="fade" scroll="false" images_loaded="true" button_label="Load More"]');

    • This topic was modified 6 years, 10 months ago by ddpweb.

    The page I need help with: [log in to see the link]

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter ddpweb

    (@ddpweb)

    Here is the full Query I’m using

    <?php       	 
    // Standard Query
       $args = array(
          'post_type' => 'post',
    	   'cat' => get_query_var('cat'),
          'posts_per_page' => 24,
    	  'offset' => 1
    	     );
       $query = new WP_Query($args);   
       
     define("SS_BLOG_NUM_COLUMNS", 3);
      
       while ( $query->have_posts() ) : $query->the_post();
       	$do_not_duplicate[] = $post->ID; // Store post ID in array
            // Other loop actions would go here
      
    ?>
     <?php get_template_part( 'content-grid', get_post_format() ); ?>  
    
      <?php
       endwhile; wp_reset_query();
       
       // Ajax Load More
       $post__not_in = '';
       if($do_not_duplicate){
          $post__not_in = implode(',', $do_not_duplicate); 
       } 
       echo do_shortcode('[ajax_load_more  post__not_in="'.$post__not_in.'" container_type="div" post_type="post" posts_per_page="24" pause="true" transition="fade" scroll="false" images_loaded="true" button_label="Load More"]');  
    ?>
    Plugin Author Darren Cooney

    (@dcooney)

    Hi @ddpweb;
    On the website there are some examples you can see.
    https://connekthq.com/plugins/ajax-load-more/docs/code-samples/

    Category:
    https://connekthq.com/plugins/ajax-load-more/docs/code-samples/category-archives/

    And in your WP Admin under Help/Examples there is a complete archive solution:
    /wp-admin/admin.php?page=ajax-load-more-help&section=examples

    Hope this helps.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Loading all categories, I need it to load only the category it’s on’ is closed to new replies.