WordPress.org

Ready to get started?Download WordPress

Forums

Jetpack by WordPress.com
Infinite Scroll Page Templates (12 posts)

  1. jacob0601
    Member
    Posted 1 year ago #

    I am trying to get the infinite scroll module working on a custom page template.

    I've read some forum posts suggesting that it is not possible to have infinite scroll work on page templates (but the posts are several months old).

    Is this still not possible? I see a couple websites doing exactly that lately (page templates + jetpack infinite scroll).

    What would be the best way to go about this?

    http://wordpress.org/extend/plugins/jetpack/

  2. Jeremy Herve
    Happiness Engineer
    Plugin Author

    Posted 1 year ago #

    We discussed about this issue here:
    http://wordpress.org/support/topic/infinite-scroll-not-loading-in-search-results?replies=5

    You should be able to adapt the code I gave there to add Infinite Scroll support to your own page template.

  3. jacob0601
    Member
    Posted 1 year ago #

    Thanks Jeremy! That actually helped me enable IS with my search queries (which was something else I was hoping to get).

    I still can't seem to get it to work with my page template. To enable support for search queries, I just modified line 876 to include is_search() which worked fine.

    I thought the same would go for pages by adding support via is_page() to the same line, but that didn't work. I then decided to try a custom function, like you suggested in the other posts. So, I removed my alterations to the line 876 and added the function (to my functions.php), which included enabling support for search queries and pages via is_**(). Once again, support for search queries was added but not for pages.

    Since I am trying to get IS to function with a specific template I tried is_page( 'template_name' ) but that did not work either.

    I am really scratching my head over here; unfortunately the site is not live or I would link it and the theme is custom so I can't reference any theme either.

    I do notice that the script is not initializing on my pages but is on everywhere else I added support. As you can see in this screenshot, the script is loaded on my home screen, but not on my page template (even with the added support via the function).

    I am thinking maybe it has something to do with my query on the page template? Could that be causing it?

    This is how I am getting posts on the page template:

    <?php $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
    	$args = array('paged' => $paged );
    	$wp_query = new WP_Query($args);
    	while ( have_posts() ) : the_post(); ?>
    	<?php get_template_part( 'content', get_post_format() ); ?>
    	<?php endwhile; ?>
    <?php wp_reset_postdata(); ?>

    Do I need to change the render property to get IS to accept this?

    Thanks again!

  4. Jeremy Herve
    Happiness Engineer
    Plugin Author

    Posted 1 year ago #

    is_page() or is_page( 'template_name' ) wouldn't help, because these two conditional tags refer to single pages, displaying a single Page and its content.

    What is the difference between your custom page template and the home page? If you want to display a list of blog posts on that custom page template, what happens when you set it as your Posts Pages in Settings > Reading in your dashboard? This Page would then return true for is_home().

  5. jacob0601
    Member
    Posted 1 year ago #

    The only difference between my blog post list (index) and the my custom page template is the way I grab the posts. Basically I wanted one page to display the most recent posts and another page to display the posts sorted by a meta value. In theory I thought that would work by having the front page (display latest posts) and make a page template that would dis play posts sorted by my choosing (meta value).

    If I used the same loop query:

    <?php while ( have_posts() ) : the_post(); ?>
    	<?php get_template_part( 'content', get_post_format() ); ?>
    <?php endwhile; ?>

    in a page template, it only returns the actual page, so thats why I used a different method of grabbing the posts (pasted above).

    The goal was to have 2 blog posts pages, each ordered differently.

    If I change my posts page to the page template, IS works fine, yes.

    It seems I am a bit out of my depth here and probably going about this the wrong way, but since is_page() will only enable IS for the actual content of the page, do you have any recommendation for obtaining the behavior I am hoping to get?

    Thanks again.

  6. jacob0601
    Member
    Posted 1 year ago #

    For now I just changed my index sort order with a pre_get_posts function and link to the chronological query via an archive links; until I can figure out a better way.

  7. Jeremy Herve
    Happiness Engineer
    Plugin Author

    Posted 1 year ago #

    What happens when you don't limit Infinite Scroll to any pages, like so:

    function tweakjp_custom_is_support() {
    	$supported = current_theme_supports( 'infinite-scroll' );
    
    	return $supported;
    }
    add_filter( 'infinite_scroll_archive_supported', 'tweakjp_custom_is_support' );
  8. jacob0601
    Member
    Posted 1 year ago #

    It still doesn't load on pages if I make that change. The page is paginated though and manually going through the pages works.

    The website that I saw that had multiple 'pages' using Jetpack IS was somehow 'tricking' IS into think the page was home. So there were two sections with body class = home. Maybe that's the key to getting it to work?

    Not totally sure how I'd go about doing that, but using the archive year to sort chronologically and and changing the home sorting with pre_get_posts works pretty well, so I can't complain.

  9. Jeremy Herve
    Happiness Engineer
    Plugin Author

    Posted 1 year ago #

    Could you contact me through this contact form, and let me know your site URL, or send me a copy of your theme, so I can run some tests on my end?

    Thanks!

  10. jacob0601
    Member
    Posted 1 year ago #

    Sure can. As soon as it goes live, I'll send you a message (should be in the next day or two).

    Thanks:)

  11. gixty7
    Member
    Posted 5 months ago #

    Hello there,

    I also have this same problem. I am using twenty twelve theme and made a custom page template where I get the posts by using WP_Query.

    I implemented the function that allows IS to run on every page. The loading gif appears but no posts are loaded.

    Pagination is also working.

  12. Jeremy Herve
    Happiness Engineer
    Plugin Author

    Posted 5 months ago #

    @gixty7 Could you please start your own thread, as per the Forum Welcome?
    http://wordpress.org/support/plugin/jetpack#postform

    It would also be useful if you could give me more information about the code you used, and where I can see Infinite Scroll in action on your site.

    Thank you!

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic