Site logo

Archived topic

Load more button on AMP

7 replies · Started by ETO on November 22, 2020

Viewing posts 1–8 of 8

The load more button does not work on AMP pages.

Hi there,

Load More requires Javascript - and AMP pages do not allow Javascript.
You could try adding this PHP Snippet to disable the Load more on AMP Pages:

add_filter( 'option_generate_blog_settings', 'db_disable_infinite_scroll_amp' );
function db_disable_infinite_scroll_amp( $options ) {
    if ( function_exists( 'is_amp_endpoint' ) && is_amp_endpoint() ) {
        $options['infinite_scroll'] = false;
	    $options['infinite_scroll_button'] = false;
    }
    return $options;
}

More info on the filter:
https://docs.generatepress.com/article/option_generate_blog_settings/

Can I add this PHP code using elements > hook ?

Hi,

Can I add this PHP code using elements > hook ?

It isn't recommended as it can cause issues.

This should ideally be added to a Child theme's functions.php or by using plugins like Code Snippet plugin. - https://docs.generatepress.com/article/adding-php/

Thank you so much! I added the code and it hides the load more button. But, there appears pagination instead of load more button.

Could you please give me the necessary code to hide the pagination on these page on AMP pages?

Just to confirm, you're wanting to remove pagination completely on AMP?

Yes, I want to remove them as they do not appear on normal pages. I do not want them to be indexed by Google.

You could try this:

add_action( 'wp_head', function() {
    if ( function_exists( 'is_amp_endpoint' ) && is_amp_endpoint() ) {
        echo '<style>.paging-navigation {display: none;}</style>';
    }
} );
This archived topic is closed to new replies.