Skip to content

Instantly share code, notes, and snippets.

@milindmore22
Created September 1, 2021 16:57
Show Gist options
  • Save milindmore22/3321c5eb54c9bf2f8c2121084d0c5f8c to your computer and use it in GitHub Desktop.
Save milindmore22/3321c5eb54c9bf2f8c2121084d0c5f8c to your computer and use it in GitHub Desktop.
Code Snippets for AMP infinite Scroll plugin
<?php
/**
* Install the AMP Infinite Scroll Plugin and use the code snippet for your active theme.
* @link https://github.com/milindmore22/amp-infinite-scroll
*/
/**
* Twenty Twenty One
*/
add_filter(
'amp_infinite_scroll_configs',
function( $config ) {
$config = array(
'footer' => array( 'site-footer' => 'footer' ),
'next_page_hide' => array(
'widget-area' => 'aside',
'pagination' => 'nav',
'site-header' => 'header',
),
);
return $config;
}
);
/**
* Twenty Twenty
*/
add_filter(
'amp_infinite_scroll_configs',
function( $config ) {
$config = array(
'footer' => array( 'header-footer-group' => 'footer' ),
'next_page_hide' => array(
'header-footer-group' => 'header',
'pagination-wrapper' => 'div',
'footer-nav-widgets-wrapper' => 'div',
),
);
return $config;
}
);
/**
* Twenty Nineteen
*/
add_filter(
'amp_infinite_scroll_configs',
function( $config ) {
$config = array(
'footer' => array( 'site-footer' => 'footer' ),
'next_page_hide' => array(
'site-header' => 'header',
'widget-area' => 'aside',
'pagination' => 'nav',
),
);
return $config;
}
);
/**
* Astra.
*/
add_filter(
'amp_infinite_scroll_configs',
function( $config ) {
$config = array(
'footer' => array( 'site-footer' => 'footer' ),
'next_page_hide' => array(
'site-header' => 'header',
'widget-area' => 'div',
'ast-pagination' => 'div',
),
);
return $config;
}
);
/**
* Neve.
*/
add_filter(
'amp_infinite_scroll_configs',
function( $config ) {
$config = array(
'footer' => array( 'site-footer' => 'footer' ),
'next_page_hide' => array(
'header' => 'header',
'page-numbers' => 'ul',
),
);
return $config;
}
);
/**
* Generatepress Default header layout
*/
add_filter(
'amp_infinite_scroll_configs',
function( $config ) {
$config = array(
'footer' => array( 'site-footer' => 'div' ),
'next_page_hide' => array(
'site-header' => 'header',
'paging-navigation' => 'nav',
'is-right-sidebar' => 'div',
),
);
return $config;
}
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment