Enable Jetpack Infinite Scroll on Portfolio

Hello, I found this thread on adding Jetpack’s infinite scroll to X Theme’s blog and have successfully implemented it on my website here.

I would like to enable infinite scroll on my portfolio index page as well. Based on what I know, the jetpack_infinite_scroll_render function needs to render the portfolio posts. I tried to change it from this:

function jetpack_infinite_scroll_render() {
  $is_filterable_index = is_home() && x_get_option( 'x_ethos_filterable_index_enable' ) == '1';
  if ( $is_filterable_index ) :
    x_get_view( 'ethos', '_index' );
  else :
    x_get_view( 'global', '_index' );
  endif;
}

to this:

function jetpack_infinite_scroll_render() {
    if (get_post_type() == 'post') {
      $is_filterable_index = is_home() && x_get_option( 'x_ethos_filterable_index_enable' ) == '1';
      if ( $is_filterable_index ) :
        x_get_view( 'ethos', '_index' );
      else :
        x_get_view( 'global', '_index' );
      endif;
    } else if (get_post_type() == 'x-portfolio') {
      x_get_view( 'integrity', 'content', 'portfolio');
    }
}

To no avail. I have tried a couple different attempts, but the portfolio page remains the same.

Not sure if there are additional steps for applying infinite scroll to CPT, or if I am not getting the rendering code correctly. Any help would be greatly appreciated!

Hello @jessebrito,

Thanks for writing in!

Please be advise that the Portfolio index is using the Layout - Portfolio page template. You should be using:

x_get_view( 'global', '_portfolio' );

Regretfully this request is beyond the scope of our support.

Note: We are unable to provide support for customizations under our Support Policy. If you are unfamiliar with code and resolving potential conflicts, you may select our One or Care service for further assistance.

Thank you for your understanding.

Okay, I understand the policy. However I must be missing something from X Theme for rendering the portfolio posts. Upon reading Jetpack’s documentation again I see:

The function must include the while() portion of WordPress’ loop and can utilize any function available to the theme when it renders posts.

I believe I need to correct my function jetpack_infinite_scroll_render by adding a WordPress loop, and I am missing X Theme functions/code for rendering the portfolio posts?

I have also updated my code to include a filter infinite_scroll_archive_supported:

/* Add inifinite scroll support for blog and portfolio */
function jetpack_infinite_scroll_support() {
    $supported = current_theme_supports( 'infinite-scroll' ) && ( is_home() || is_post_type_archive('post') || is_post_type_archive('x-portfolio') );

    return $supported;
}
add_filter( 'infinite_scroll_archive_supported', 'jetpack_infinite_scroll_support' );

This works as my blog still has infinite scroll, but no luck on the portfolio archives so far.
Thank you for the insight. If I can be pointed in the right direction to render the portfolio posts that’d be great!

Hey @jessebrito,

If you’re looking for the while loop, the file you should be working on is _portfolio.php which is located in \wp-content\themes\pro\framework\views\global.

If you don’t know how to override theme files yet, please check our theme customization guide here https://theme.co/docs/best-practices

That is all we can provide for this case as we can only point you to the theme files you need.

Hope that helps and thank you for understanding.

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.