Guest User

Untitled

a guest
Nov 29th, 2017
139
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.63 KB | None | 0 0
  1. $(window).scroll(function () {
  2. if (!loading && scrollHandling.allow) {
  3. scrollHandling.allow = false;
  4. setTimeout(scrollHandling.reallow, scrollHandling.delay);
  5. if ($(document).scrollTop() > ($(document).height() - bottomOffset) && canBeLoaded == true) {
  6. if ($checkbox.is(':checked')) {
  7. categoryIDs.indexOf(value) === -1 ? (
  8. categoryIDs.push(value)
  9. ) : (
  10. categoryIDs = categoryIDs.filter((item) => item !== value)
  11. )
  12. } else {
  13. categoryIDs = [3, 4, 28, 35, 353];
  14. // TODO: move this to the functions.php file if possible? if/else to reset var to initial array if AJAX returns empty?
  15. }
  16.  
  17. $.ajax({
  18. type: 'POST',
  19. url: afp_vars.afp_ajax_url,
  20. data: {
  21. action: "afp_load_more",
  22. page: page,
  23. query: afp_vars.query,
  24. category__in: categoryIDs
  25. },
  26. success: function (res) {
  27. $(".filter-section").append(res);
  28. page += 1;
  29. }
  30. })
  31. }
  32. }
  33. });
  34.  
  35.  
  36. /****************************/
  37. function afp_load_more() {
  38. $args = isset( $_POST['query'] ) ? array_map( 'esc_attr', $_POST['query'] ) : array();
  39. $args['post_type'] = isset( $args['post_type'] ) ? esc_attr( $args['post_type'] ) : 'post';
  40. $args['paged'] = esc_attr( $_POST['page'] );
  41. $args['post_status'] = 'publish';
  42. $args['category__in'] = $_POST['category__in']; // Change here
  43. $args['order'] = 'DESC';
  44. $args['orderby'] = 'date';
  45. $args['offset'] = 9;
  46. $args['posts_per_page'] = 9;
  47. var_dump($args);
  48. ob_start();
Add Comment
Please, Sign In to add comment