Problem with Polylang plugin in AJAX filter
-
Please tell me what could be the reason for the filter not working correctly.
The site has several languages
The filter works via AJAX
In the main EN language, everything is ok. The filter is working correctly. But on an additional RU, when using a filter, records are displayed not only RU but also with EN. (I noticed that when logged in, then only EN is displayed in incognito when choosing a category). I can’t figure out what is the reason. Tell me pleaselink to the page
admin
stageadd_action('wp_ajax_filter_posts', 'enrlaw_filter_posts'); add_action('wp_ajax_nopriv_filter_posts', 'enrlaw_filter_posts'); function enrlaw_filter_posts() { echo '<pre>'; echo '</pre>'; $args = array( 'post_type' => explode(" ", $_POST['postType']), 'orderby' => 'date', // we will sort posts by date 'order' => 'DESC', // ASC or DESC 'paged' => get_query_var('paged'), ); if(isset( $_POST['postCategory'] )) { $termsIDs = $_POST['postCategory']; $args['tax_query'] = array( array( 'taxonomy' => 'publication_category', 'field' => 'id', 'terms' => $termsIDs, 'operator' => 'AND' ), ); } $query = new WP_Query($args); if($query->have_posts()) : echo '<div class="flex-container">'; while($query->have_posts()) { $query->the_post(); echo '<div class="flex-xl-4 flex-lg-6 flex-xs-12">'; get_template_part('template-parts/tpl', 'post-preview'); echo '</div>'; } echo '</div>'; if ( $query->max_num_pages > 1 ) : ?> <button class="main-button main-button--center posts_loadmore" data-ajaxurl='<?php echo site_url('wp-admin/admin-ajax.php'); ?>' data-query='<?php echo addslashes(json_encode($query->query_vars)); ?>' data-current-page='<?php echo (get_query_var('paged')) ? get_query_var('paged') : 1; ?>' data-max-pages='<?php echo $query->max_num_pages; ?>' > <?php _e('View more', 'enrlaw'); ?> </button> <?php endif; endif; wp_reset_postdata(); wp_reset_query(); die(); }
The page I need help with: [log in to see the link]
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Problem with Polylang plugin in AJAX filter’ is closed to new replies.