[Resolved] Divide infinite scroll for mobile version

Home Forums Support [Resolved] Divide infinite scroll for mobile version

Home Forums Support Divide infinite scroll for mobile version

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #877450
    Rust

    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.

    #878191
    Tom
    Lead Developer
    Lead Developer

    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).

    #878621
    Rust

    super, thanks!

    #879259
    Tom
    Lead Developer
    Lead Developer

    You’re welcome 🙂

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