Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $(window).scroll(function () {
- if (!loading && scrollHandling.allow) {
- scrollHandling.allow = false;
- setTimeout(scrollHandling.reallow, scrollHandling.delay);
- if ($(document).scrollTop() > ($(document).height() - bottomOffset) && canBeLoaded == true) {
- if ($checkbox.is(':checked')) {
- categoryIDs.indexOf(value) === -1 ? (
- categoryIDs.push(value)
- ) : (
- categoryIDs = categoryIDs.filter((item) => item !== value)
- )
- } else {
- categoryIDs = [3, 4, 28, 35, 353];
- // TODO: move this to the functions.php file if possible? if/else to reset var to initial array if AJAX returns empty?
- }
- $.ajax({
- type: 'POST',
- url: afp_vars.afp_ajax_url,
- data: {
- action: "afp_load_more",
- page: page,
- query: afp_vars.query,
- category__in: categoryIDs
- },
- success: function (res) {
- $(".filter-section").append(res);
- page += 1;
- }
- })
- }
- }
- });
- /****************************/
- function afp_load_more() {
- $args = isset( $_POST['query'] ) ? array_map( 'esc_attr', $_POST['query'] ) : array();
- $args['post_type'] = isset( $args['post_type'] ) ? esc_attr( $args['post_type'] ) : 'post';
- $args['paged'] = esc_attr( $_POST['page'] );
- $args['post_status'] = 'publish';
- $args['category__in'] = $_POST['category__in']; // Change here
- $args['order'] = 'DESC';
- $args['orderby'] = 'date';
- $args['offset'] = 9;
- $args['posts_per_page'] = 9;
- var_dump($args);
- ob_start();
Add Comment
Please, Sign In to add comment