• Resolved gasmas75

    (@gasmas75)


    Hi all,
    Testing Infinite Scroll in a development environment. I am using a custom theme based on underscores.me starter theme. Infinite scroll is working fine in archive pages (both tag and category) but it doesn’t work on the single post page.
    I have a section under the main loop with ‘Read Also’ and want to use there the inf loop.
    This is the code from the single.php:

    
    <section class="related-posts-container">
     <span class="read-also">
      <span>Read Also</span>
     </span>
     <div id="infinite" class="related-posts">
    <?php
     $categories = get_the_category($post->ID);
     $catid = $categories[0]->cat_ID;
     $currpost[] = get_the_ID();
     $args = [
     'post_type' => 'post',
     'post_status' => 'publish',
     'orderby' => 'DESC',
     'cat' => $catid,
     'post__not_in' => $currpost,
      ];
     $query = new WP_Query( $args );
    if ($query->have_posts()) : while ($query->have_posts()) : $query->the_post();
      get_template_part('template-parts/infinite');
    endwhile;
    endif;
    ?>
    </div> <!--End Infinite Loop -->
    </section> <!--End Related Posts Container-->
    

    This is the altered code from jetpack.php:

    add_theme_support( 'infinite-scroll', array(
       'container' 	    => 'infinite',
       'render'    	    => 'ths_infinite_scroll_render',
       'footer'    	    => false,
       'wrapper'	    => true,
       'posts_per_page' => 6,
    ) );

    And the renderer function:

    function ths_infinite_scroll_render() {
      while ( have_posts() ) {
         the_post();
    	if ( is_search() ) :
    	  get_template_part( 'template-parts/content', 'search' );
    	else :
    	  get_template_part( 'template-parts/infinite', get_post_format() );
    	endif;
    	}
    }

    Is it because it’s in locahost? Is there something i’m missing on Jetpack setup?
    I’ve tried other infinite scroll plugins and they work (with a shortcode though). I’ve tried TwentyTwenty theme and have the same problem.
    Please advice.

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Support fresatomica

    (@fresatomica)

    Hi there!

    I’m afraid that custom code is outside the scope of what we’re able to offer in support here.

    You can have a look at the snippets from here but, if you need help with that, we recommend hiring someone from https://jetpack.pro/

    Thread Starter gasmas75

    (@gasmas75)

    Hi @fresatomica ,
    Thank you for your reply. I understand that. Even though it isn’t such customized, since it’s the basic underscores theme with some minor alternations on the Jetpack Inf Scroll call.
    But I respect that.
    Could you please just tell me if there are issues with a localhost environment affecting the Inf Scroll in any way?

    Plugin Support fresatomica

    (@fresatomica)

    Not that I am aware of but I’m wondering if your issue can have anything to do with this one. If so, feel free to comment there with more details.

    Thread Starter gasmas75

    (@gasmas75)

    Thanks @fresatomica
    I’ll investigate more and post my results here if it helps anyone.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Infinite scroll in single post’ is closed to new replies.