Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- add_theme_support( 'infinite-scroll', array(
- 'container' => 'content',
- 'footer' => false,
- 'render' => 'vividflow_infscroll_render',
- 'wrapper' => 'post_summaries',
- 'posts_per_page' => 12,
- 'type' => 'scroll'
- ) );
- function setupPostSummaries(counter) {
- jQuery('.infinite-view-'+counter).doSomething();
- }
- <script type="text/javascript">setupPostSummaries(<?php the_counter(); ?>);</script>
- <?php
- /* Plugin Name: Infinite Scroll Counter Script */
- add_action( 'wp_enqueue_scripts', 'wpse88834_add_script' );
- function wpse88834_add_script()
- {
- wp_enqueue_script(
- 'wpse_counter',
- plugin_dir_url( __FILE__ ).'js/counter.js',
- array( 'jquery' ), // the infinte scroll script should also be added as dependency
- filemtime( plugin_dir_path( __FILE__ ).'js/counter.js' ),
- true
- );
- wp_localize_script(
- 'wpse_counter',
- 'wpse_counter_obj',
- array(
- 'numberposts' => $GLOBALS['wp_query']->numberposts,
- 'found_posts' => $GLOBALS['wp_query']->found_posts,
- 'posts_per_page' => $GLOBALS['wp_query']->posts_per_page,
- )
- );
- }
- /* Inside ~/js/counter.js */
- jQuery( document ).ready( function($) {
- /* wpse_counter_obj.numberposts */
- wpse_counter_obj.found_posts
- wpse_counter_obj.posts_per_page
- // Current
- var post_count_curr = 0;
- post_count_curr += wpse_counter_obj.found_posts;
- console.log( post_count_curr );
- } );
- function setupPostSummaries() {
- jQuery('.post_summaries').last().doSomething();
- }
- $curPage = (get_query_var('paged') ? get_query_var('paged') : 1) + 1;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement