Site logo

Archived topic

Divide infinite scroll for mobile version

3 replies · Started by Rust on April 24, 2019

Viewing posts 1–4 of 4

Hi. How can i separate infinity scroll on main page and rubric pages for mobile and desktop devices?
I want that, for desktop version my blog have infinite scroll at main and rubrics pages WITHOUT "read more posts" button, and for mobile version my blog have infinite scroll WITH "read more" button, because i want to show sidebar for my readers.
thanks, and sorry for my bad english.

Hi there,

You could try something like this:

function isMobile() {
    return preg_match("/(android|avantgo|blackberry|bolt|boost|cricket|docomo|fone|hiptop|mini|mobi|palm|phone|pie|tablet|up\.browser|up\.link|webos|wos)/i", $_SERVER["HTTP_USER_AGENT"]);
}

add_filter( 'option_generate_blog_settings', function( $options ) {
    if ( isMobile() ) {
        $options['infinite_scroll_button'] = true;
    }

    return $options;
} );

Adding PHP: https://docs.generatepress.com/article/adding-php/

This would assume the button is turned off in your settings (for desktop).

super, thanks!

You're welcome :)

This archived topic is closed to new replies.