Advertisement
Guest User

Untitled

a guest
Oct 20th, 2014
229
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.62 KB | None | 0 0
  1. add_theme_support( 'infinite-scroll', array(
  2. 'container' => 'content',
  3. 'footer' => false,
  4. 'render' => 'vividflow_infscroll_render',
  5. 'wrapper' => 'post_summaries',
  6. 'posts_per_page' => 12,
  7. 'type' => 'scroll'
  8. ) );
  9.  
  10. function setupPostSummaries(counter) {
  11. jQuery('.infinite-view-'+counter).doSomething();
  12. }
  13.  
  14. <script type="text/javascript">setupPostSummaries(<?php the_counter(); ?>);</script>
  15.  
  16. <?php
  17. /* Plugin Name: Infinite Scroll Counter Script */
  18. add_action( 'wp_enqueue_scripts', 'wpse88834_add_script' );
  19. function wpse88834_add_script()
  20. {
  21. wp_enqueue_script(
  22. 'wpse_counter',
  23. plugin_dir_url( __FILE__ ).'js/counter.js',
  24. array( 'jquery' ), // the infinte scroll script should also be added as dependency
  25. filemtime( plugin_dir_path( __FILE__ ).'js/counter.js' ),
  26. true
  27. );
  28. wp_localize_script(
  29. 'wpse_counter',
  30. 'wpse_counter_obj',
  31. array(
  32. 'numberposts' => $GLOBALS['wp_query']->numberposts,
  33. 'found_posts' => $GLOBALS['wp_query']->found_posts,
  34. 'posts_per_page' => $GLOBALS['wp_query']->posts_per_page,
  35. )
  36. );
  37. }
  38.  
  39. /* Inside ~/js/counter.js */
  40. jQuery( document ).ready( function($) {
  41. /* wpse_counter_obj.numberposts */
  42. wpse_counter_obj.found_posts
  43. wpse_counter_obj.posts_per_page
  44. // Current
  45. var post_count_curr = 0;
  46. post_count_curr += wpse_counter_obj.found_posts;
  47. console.log( post_count_curr );
  48. } );
  49.  
  50. function setupPostSummaries() {
  51. jQuery('.post_summaries').last().doSomething();
  52. }
  53.  
  54. $curPage = (get_query_var('paged') ? get_query_var('paged') : 1) + 1;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement