[Resolved] Question Regarding Infinite Scroll Single Posts…

Home Forums Support [Resolved] Question Regarding Infinite Scroll Single Posts…

Home Forums Support Question Regarding Infinite Scroll Single Posts…

Viewing 15 posts - 1 through 15 (of 19 total)
  • Author
    Posts
  • #1566691
    Christopher Jan

    Hello, guys!

    I got a copy of the Ajax Load More Single Posts: https://connekthq.com/plugins/ajax-load-more/add-ons/single-posts/

    To make the plugin work, I need to replace the single.php file using the template they specifically created for GeneratePress: https://connekthq.com/plugins/ajax-load-more/docs/add-ons/single-posts/

    However, after changing the default GP single.php with the one found on the page, this is what it shows: https://mtbrules.com/what-size-specialized-mountain-bike-do-i-need/

    The infinite scroll is located on the top right above the fold. And when I scroll past above the fold, the page creates a new column to load the next page.

    Here’s the question:

    Is there something wrong with the template the plugin creator provided? And can you provide the correct code for the single.php to make the plugin work properly?

    If this is beyond your scope, I understand completely. It’s just that the plugin creator hasn’t replied to my question yet and I want to deploy the plugin across all my GP sites.

    Thanks in advance!

    #1566703
    Elvin
    Staff
    Customer Support

    Hi there,

    As this is a significant site customization that deals with third party plugins, this is out of our scope.

    But to help you out:

    I’ve checked the links from AJAX load more and the single.php file they use if pretty dated. It’s still using the 2.4.2 version while the current latest version is 3.0.2 which has a few bit of edits on its single.php (2.4.2 had 67 lines, 3.0.2 has 54 lines).

    Perhaps mentioning this to theme will give clues on which to edit from.

    3.0.2 single.php
    https://github.com/tomusborne/generatepress/blob/3.0.2/single.php

    2.4.2 single.php
    https://github.com/tomusborne/generatepress/blob/2.4.2/single.php

    A wise man once said:
    "Have you cleared your cache?"

    #1566811
    Christopher Jan

    This is helpful. Thanks!

    #1567020
    Osa

    Hi Christopher,
    I’m not a techie but I suspect you can do this without the need to modify your single.php file.
    You can do this by adding two new hook elements as follows:
    1. to open div#post-wrapper => hook into the generate_before_content
    2. to close wrapper and echo shortcode => hook into generate_after_content
    As per the implementation guide https://connekthq.com/plugins/ajax-load-more/add-ons/single-posts/
    Hopefully this helps.
    Cheers,
    Osa

    #1567026
    Christopher Jan

    Thanks for the message, Osa!

    Unfortunately, did exactly what you told me and it’s still not working.

    Thanks anyway!

    #1567061
    Osa

    Ah that’s a shame. Did you try echoing just the shortcode (without all the added parameters)?
    <?php echo do_shortcode(‘[ajax_load_more id=”#post-wrapper” post_type=”post”]’); ?>
    Just to try and isolate the issue.
    Good luck.

    #1568072
    Christopher Jan

    Hello, Osa!

    Thanks for the suggestion. At the moment, I’m getting help from the plugin developer to get the issue fixed. We’ll get back to you once he’s done working on it.

    #1568260
    Christopher Jan

    Hello, Osa!

    Quick update: I got the infinite scroll for single pages to work. Check out the site from any of the links above.

    I followed your advice. But this time, I checked the “Execute PHP” box: https://www.screencast.com/t/22JjaCdxE

    Also, on the Container layout, I used “One Container” instead of “Separate Containers,” which I think is the source of the issue.

    Hope this helps everyone!

    #1568567
    Osa

    Hi Christopher,
    Thanks for your feedback. Glad it’s all worked out.
    Where’s the “Container layout” if I may ask?
    Cheers, Osa.

    #1568591
    Christopher Jan

    No problem! I’m referring to this one: https://www.screencast.com/t/EhE3cHdK3rV

    #1568611
    Osa

    Ah I see. Would never have worked it out. Thanks for sharing!

    #1568672
    Osa

    Hi Christopher,
    I just purchased the Infinite Scroll Single Post Add On for one of my sites.
    Unfortunately I can’t get it to work.
    The shortcode is pulling from the “Repeater Template” (and ignoring the wrapper I specifically created via templates).
    Please do you mind sharing the exact steps you took to implement the plugin? If that’s ok with you.
    Thanks a lot.
    Osa.

    #1568950
    Christopher Jan

    Hello, Osa!

    Sure thing! Before I help, keep in mind that I have zero experience in coding and am very new to using GeneratePress. So I’ll show what worked for my site – I can’t guarantee it would work for you (although I think it should work).

    Here’s how I did it:

    1) Install Ajax Load More plugin then the Single Post add-on plugin. Enter the license key.
    2) Leave the settings as they are.
    3) Go to Appearance > Elements, create new Hook, and enter this line of code:
    <div id="alm-post-wrap">
    then insert hook on generate_before_content. Screenshot: https://www.screencast.com/t/5VRpdgUn
    For Display Rules, choose Posts > All Posts. Screenshot: https://www.screencast.com/t/DYGeK3lTctav
    Then publish.
    4) Create another hook element and enter this line of code:

    </div>
    
    <?php 
    	
    // Ajax Load More
    $args = array(
    	'single_post' 			=> 'true',
    	'single_post_id' 		=> get_the_ID(),
    	'single_post_target'	=> '#alm-post-wrap',
    	'post_type' 			=> 'post',
    	'pause_override' 		=> 'true',
    );	
     
    if( function_exists( 'alm_render' ) ){
    	alm_render($args);
    }
     
    ?>

    Insert hook in generate_after_content.
    Then check Execute PHP box.
    Screenshot: https://www.screencast.com/t/uGG6hJW9v
    Same Display Rules as above.

    That’s it!

    I didn’t use the plugin’s shortcode generator for the infinite scroll. I used the one from its documentation for GeneratePress: https://connekthq.com/plugins/ajax-load-more/docs/add-ons/single-posts/

    Hope this helps!

    #1569116
    Osa

    Hi Christopher,
    Thanks a lot for your help.
    I’m still running into the same issue.
    The problem is that it doesn’t work when I target the #alm-post-wrap with the single_post_target.
    I think this has to do with my single.php file structure.
    I’m using the “dispatch” template. I’ll look into it later.
    Thanks again for your kind assistance.
    It’s very much appreciated.

    PS,

    You need to add the template tags {post-title} – {site-title} to your ALM settings.
    So that your page titles can change along with the posts when scrolling.
    Currently, from your site link above, only the urls are changing. Page title is the same as the original article (if that makes sense).
    Ajax Load More Settings => Single Post Settings > Page Title Template

    #1569393
    Christopher Jan

    No worries, Osa!

    Try the 3.0.2 version of the single.php here:
    https://github.com/tomusborne/generatepress/blob/3.0.2/single.php

    P.S. Thanks for that! Will work on this soon.

Viewing 15 posts - 1 through 15 (of 19 total)
  • You must be logged in to reply to this topic.