@LastGeneral

Как вывести фильтр на всех языках?

Реализован вывод фильтров продуктов, сейчас выводиться только на русском языке, на других нет. Когда меняю $main_page = pll_get_post(18); id на id другой страницы, другого языка, отображается фильтр на этом языке. Как сделать так что бы они показывались на всех языках?
$locale = get_locale();
if($locale == 'ru_RU'){
    $all_text = 'Все';
    $subcat_text = 'Категории';
    $seria_text = 'Серии';
    $ing_text = 'Ингридиенты';
    $reset_filters = 'Сбросить фильтры';
    $no_products = 'В этой категории нет товаров.';
    $filter_but = 'Применить фильтры';
}else if($locale == 'uk'){
    $all_text = 'Все';
    $subcat_text = 'Категорії';
    $seria_text = 'Серії';
    $ing_text = 'Cкладові';
    $reset_filters = 'Скинути фільтри';
    $no_products = 'В цій категорії немає товарів.';
    $filter_but = 'Застосувати фільтри';
}else{
    $all_text = 'All';
    $subcat_text = 'Categories';
    $seria_text = 'Series';
    $ing_text = 'Ingredients';
    $reset_filters = 'Reset filters';
    $no_products = 'There are no products in this category.';
    $filter_but = 'Apply filters';
}
$id = get_the_ID();
$my_wp_query = new WP_Query();
$all_wp_pages = $my_wp_query->query(array('post_type' => 'page', 'posts_per_page' => -1 ));
$main_page = pll_get_post(18);
$children_pages = get_page_children($id,$all_wp_pages);
$children_pages_filter = get_page_children($main_page,$all_wp_pages);
$ids = array();
foreach ($children_pages as $children_page) {
    $ids[] = $children_page->ID;
}
if(!empty($ids)){
    $meta_array = array();
    $meta_array['relation'] = 'OR';
    foreach($ids as $id2){  // CREATE QUERY FOR EACH COUNTRY IN ARRAY

        $meta_array[] =  array(
            'key'		=> 'product_category',
            'value'		=> $id2,
            'compare'	=> 'LIKE'
        );

    }
}else{
    $meta_array[] =  array(
        'key'		=> 'product_category',
        'value'		=> $id,
        'compare'	=> 'LIKE'
    );
}

?>
<?php
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
if($id == $main_page){
    $data= new WP_Query(array(
        'post_type'=> 'products', // your post type name
        'posts_per_page' => 15, // post per page
        'paged' => $paged
    ));
}else{
    $data= new WP_Query(array(
        'post_type'=> 'products', // your post type name
        'posts_per_page' => 15, // post per page
        'paged' => $paged,
        'meta_query'	=> $meta_array
    ));
}?>

Ссылка на полный код
  • Вопрос задан
  • 54 просмотра
Решения вопроса 1
@weart
18 - это id текущей страницы?
Если да, то должно помочь

$main_page = get_post($id);
Ответ написан
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы