Last active
November 22, 2021 09:26
-
-
Save devinsays/399e8c6966360dbac708ffff4178b780 to your computer and use it in GitHub Desktop.
Infinite Scroll
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| /** | |
| * Load javascripts used by the theme | |
| */ | |
| function custom_theme_js() { | |
| wp_register_script( | |
| 'infinite_scroll', | |
| get_template_directory_uri() . '/js/infinite-scroll.pkgd.min.js', | |
| array('jquery') | |
| null, | |
| true | |
| ); | |
| if ( ! is_singular() ) { | |
| wp_enqueue_script( 'infinite_scroll' ); | |
| } | |
| } | |
| add_action( 'wp_enqueue_scripts', 'custom_theme_js' ); | |
| /** | |
| * Infinite Scroll | |
| */ | |
| function custom_infinite_scroll_js() { | |
| if ( ! is_singular() ) { ?> | |
| <script> | |
| var infinite_scroll = { | |
| loading: { | |
| img: "<?php echo get_template_directory_uri(); ?>/images/ajax-loader.gif", | |
| msgText: "<?php _e( 'Loading the next set of posts...', 'custom' ); ?>", | |
| finishedMsg: "<?php _e( 'All posts loaded.', 'custom' ); ?>" | |
| }, | |
| "nextSelector":"#nav-below .nav-previous a", | |
| "navSelector":"#nav-below", | |
| "itemSelector":"article", | |
| "contentSelector":"#content" | |
| }; | |
| jQuery( infinite_scroll.contentSelector ).infinitescroll( infinite_scroll ); | |
| </script> | |
| <?php | |
| } | |
| } | |
| add_action( 'wp_footer', 'custom_infinite_scroll_js', 100 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment