Site logo

Archived topic

Remove infinite scroll navigation on other categories

3 replies · Started by Ryan on October 18, 2022

Viewing posts 1–4 of 4

I have infinite scroll enabled on my main articles category, but also have two other categories that use custom templates for the category page. I'm trying to disable the infinite scroll navigation link that goes to /page/2, /page/3, etc. because those pages are all identical to page 1 due to the templates being used.

Can the infinite scroll feature be filtered in some way to be active only on the articles category? I tried filtering the generate_blog_do_infinite_scroll_path function and also doing a custom function to override in my theme but neither worked. I know there is also some javascript involved so I don't know if just removing the <div class="infinite-scroll-path"> code would result in a JS error. Also, disabling the infinite scroll does not remove the links.

Thanks that worked great to remove the page navigation. Only issue is when removing the infinite scroll, it also removes the CSS that enables the 'generate-columns' code like 'tablet-grid-50', 'mobile-grid-100', etc. I tried using $options['column_layout'] = true but that did not add the CSS back in. Is there a way to load the /gp-premium/blog/functions/css/style.min.css and also disable infinite scroll? I'm guessing that would have to be a separate wp_enqueue_style dependent on the archive loading?

UPDATE: You can disregard unless there is a sleeker solution. The conditional wp_enqueue_style on the columns.min.css file worked fine.

That is odd, this works for me, and doesn't affect the columns:


add_filter( 'option_generate_blog_settings', 'lh_custom_search_results_page_settings' );
function lh_custom_search_results_page_settings( $options ) {
    if ( is_category(array(12,15)) ) {
        $options['infinite_scroll'] = false;
    }
  
    return $options;
}
This archived topic is closed to new replies.