Dudaevskiy
10/14/2019 - 9:21 PM

ACF jQuery back filter

// ========================================================================================
// При возврате на страницу где ранее применен фильтр, применим фильтр снова
// START
// ideisruba
// $('[data-e="price1"]').trigger('click');
// =======================================================================================
function remove(arrOriginal, elementToRemove){
    return arrOriginal.filter(function(el){return el !== elementToRemove});
}
// console.log( remove([1, 2, 1, 0, 3, 1, 4], 1) );

jQuery(document).ready(function($){


//1️⃣
// Удаление из хеша того фильтра который удален через верхнее меню удаления фильтров
$('.filters-show').on('DOMNodeRemoved','.filter-item-accept',function(){
// 				console.log('🗃 Да, было применение фильтрации');
				var ThisRemovFilter = $(this).attr('data-e');
				var ThisRemovFilterForFind = "[data-e=\""+ThisRemovFilter+"\"]";
// 				console.log("Был удален фильтр - "+ThisRemovFilter);
				
				// Узнаем Name удаленного фильтра:
				ThisRemovFilterForFind = $('body .row.row-page-prod').find(ThisRemovFilterForFind).attr('name');
                    
					var ParamNameRem = ThisRemovFilterForFind;
                    // Данные выбранного фильтра
                    var ParamDataERem = ThisRemovFilter;
					var FilterDataRem = "#FILTER-"+ParamNameRem+"-and-"+ParamDataERem;
// 				console.log(FilterDataRem);
			// Текущий хеш
			var Hash = document.location.hash;
			var HashRep = Hash.replace(/#FILTER-/g,"|#FILTER-");
			
// 				console.log("🔎 HashRep = "+HashRep);

			var HashSplit = HashRep.split('|');
// 				console.log("✂ HashSplit = "+HashSplit);


			if (jQuery.inArray(FilterDataRem, HashSplit)!='-1') {
				 var addURLRem = remove(HashSplit,FilterDataRem);
				     addURLRem = addURLRem.toString().replace(/,/g,"");
				document.location.hash = addURLRem;
			} 


});

//2️⃣
// Удаление из хеша того фильтра который удален через верхнее меню удаления фильтров
$('body .filters-show').on('DOMNodeRemoved','.filter-all-remove',function(){

			// Чудо функция которая отменяет повторное срабатывание клика ПРИ on
// 			$(this).on('DOMNodeRemoved', function(evt) {
//                evt.stopPropagation();
//             // console.log("Повторный клик для .on был отменен");
//             });

			document.location.hash = '';

				console.log('🧹 Да, было удаленеи всех фильтров');
});

//     $(window).on('load', function () {

		var OriginalURL = document.location.href;

// Захватываем данные из только что кликнутого пункта
//  фильтрации и обрабатываем

//3️⃣
$('.row-page-prod').on('change','.filters-c label input',function(){
			
			console.log('👆 есть');
			
			// Чудо функция которая отменяет повторное срабатывание клика ПРИ on
// 			$(this).on('change', function(evt) {
//                evt.stopPropagation();
//             // console.log("Повторный клик для .on был отменен");
//             });


			//1️⃣
			// Имя выбранного фильтра
            var ParamName = $(this).attr('name');
			// Данные выбранного фильтра
			var ParamDataE = $(this).attr('data-e');
			// Преобразование для вставки в анкор ссылки
			var FilterData = ParamName+"-and-"+ParamDataE;

            // Готовый текст фильтра для вставки в конец адреса данных отмеченного фильтра
            var addURL = "#FILTER-"+FilterData;
			

			//2️⃣
			// Текущий хеш
			var Hash = document.location.hash;
				console.log("🔗 Hash до = "+Hash);
			
			// Делим хеш по данным фильра
// добавляем разделитель |
var HashRep = Hash.replace(/#FILTER-/g,"|#FILTER-");
console.log("🔎 HashRep = "+HashRep);

			var HashSplit = HashRep.split('|');
				console.log("✂ HashSplit = "+HashSplit);

		//🔴🔴🔴🔴🔴🔴🔴🔴🔴🔴🔴🔴🔴🔴🔴🔴🔴	
    if(this.checked) {
      // checkbox is checked
console.log("👍👍👍да отмечено");
    }
			// Делаем проверку на наличие текущего фильтра в хеше
			if (jQuery.inArray(addURL, HashSplit)!='-1') {
// 			if(this.checked && jQuery.inArray(addURL, HashSplit)!='-1') {

					console.log("1️⃣HashSplit До удаления = "+HashSplit);
// 					console.log(HashSplit);

              	    addURL = remove(HashSplit,addURL);
					addURL = addURL.toString().replace(/,/g,"");
// 					addURL = addURL.replace(/,/g,"");
					console.log("2️⃣✂ HashSplit После удаления = "+addURL);
					console.log(HashSplit);
				
	            	console.log("😎✅ Текущий фильтр "+ FilterData +" Есть в текущем хеше"+HashSplit);

			} else {

				addURL = Hash + addURL;
				console.log("😎🔴 Текущий фильтр "+ FilterData +" Не есть в текущем хеше"+HashSplit);

			}

		//🔴🔴🔴🔴🔴🔴🔴🔴🔴🔴🔴🔴🔴🔴🔴🔴🔴

			console.log("🔗🔗 Hash = "+Hash);

			
			//3️⃣
            // Текущая ссылка страницы
            var Location = document.location.href;


//             var NewURL = OriginalURL+addURL;
//             console.log("🔗 NewURL = "+ NewURL);
            console.log("🔗 NewURL = "+ addURL);
            document.location.hash = addURL;

		});




});


// ========================================================================================
// END
// При возврате на страницу где ранее применен фильтр, применим фильтр снова
// ========================================================================================
jQuery(document).ready(function($){
 
 
    //1️⃣
    // Удаление из хеша того фильтра который удален через верхнее меню удаления фильтров
    $('.filters-show').bind('DOMSubtreeModified',function(){

        console.log('🗃 Да, было применение фильтрации');
    	var HashLink = [];



    $(this).each(function(){

       var datae = $(this).find('.filter-item-accept').attr('data-e');

				var ThisFilter = $(this).find('.filter-item-accept').attr('data-e');
				
				var ThisFilterForFind = "[data-e=\""+ThisFilter+"\"]";
		// Узнаем Name
		var ThisFilterForFind = $('body .row.row-page-prod').find(ThisFilterForFind).attr('name');
		var ThisFilterForFindVal = $('body .row.row-page-prod').find(ThisFilterForFind).val();
		
		var ParamNameRem = ThisFilterForFind;
        // Данные выбранного фильтра
        var ParamDataERem = ThisFilter;
// 		var FilterDataRem = "&"+ParamNameRem+""+ParamDataERem;
		var FilterDataRem = "&"+ParamNameRem+""+ThisFilterForFindVal;
		
		console.log(FilterDataRem);

    });
//     console.log(HashLink);




    });
});
 
jQuery(document).ready(function($){
 
    $('.filters-show').on("DOMNodeInserted", function (event) {

        console.log('📘 Да! Было произведено обновление меню с выбранными фильтрами');

                // Отменяем повторение событий для меню 
                $(this).on('DOMNodeInserted', function(evt) {
                   evt.stopPropagation();
                // console.log("Повторный клик для .on был отменен");
                });

        $(this).each(function(){

//            var datae = $(this).find('.filter-item-accept').attr('data-e');
// 		console.log(datae);
                    var ThisFilter = $(this).find('.filter-item-accept').attr('data-e');
		console.log("ThisFilter = " + ThisFilter);
                    var ThisFilterForFind = "input[data-e=\""+ThisFilter+"\"]";
console.log("ThisFilterForFind = " + ThisFilterForFind);

    // Узнаем имя 
    var data_sd_name = $('body .row.row-page-prod').find(ThisFilterForFind).attr('name').replace(/_/g,"-");
    console.log("data_sd_name = " + data_sd_name);
	
	// Узнаем значение
	// 1 - Если НЕ выбран тип строения, размера или цены (у нас в нутри должны быть только цифры без текста )
	// .replace(/\D+/g,"") - Выризаем цифры из текста
    if (data_sd_name !== 'type-build' || data_sd_name !==  'price' || data_sd_name !==  'size'){
        var data_sd_value = $('body .row.row-page-prod').find(ThisFilterForFind).attr('data-e').replace(/\D+/g,"");
        console.log("data_sd_value = " + data_sd_value);

	// 2 - Если выбран тип строения, размера или цены
    } 
	
	// Если type-build
	if (data_sd_name == 'type-build') {
        var data_sd_value = $('body .row.row-page-prod').find(ThisFilterForFind).attr('data-e');
        console.log("✅ да - type-build / data_sd_value = " + data_sd_value);
    }

	// Если price
	if (data_sd_name == 'price') {
		// <input class="filter-c" type="checkbox" data-e="price1" name="price" data-min="0" data-max="500000">
        var data_sd_value = $('body .row.row-page-prod').find(ThisFilterForFind).attr('data-e');
        console.log("✅ да - type-build / data_sd_value = " + data_sd_value);

		var data_sd_value_ot = $('body .row.row-page-prod').find(ThisFilterForFind).attr('data-min');
		var data_sd_value_do = $('body .row.row-page-prod').find(ThisFilterForFind).attr('data-max');

		var FullPrace = "price_ot="+data_sd_value_ot+"&price_do="+data_sd_value_do
		console.log(FullPrace);
    }
	
	// Если size
	if (data_sd_name == 'size') {
		// <input class="filter-c" type="checkbox" data-e="price1" name="price" data-min="0" data-max="500000">
        var data_sd_value = $('body .row.row-page-prod').find(ThisFilterForFind).attr('data-e');
        console.log("✅ да - type-build / data_sd_value = " + data_sd_value);

		var data_sd_value_ot = $('body .row.row-page-prod').find(ThisFilterForFind).attr('data-min');
		var data_sd_value_do = $('body .row.row-page-prod').find(ThisFilterForFind).attr('data-max');

		var FullSize = "size_ot="+data_sd_value_ot+"&size_do="+data_sd_value_do
		console.log(FullSize);
    }

	if (data_sd_name == 'another') {
		// <input class="filter-c" type="checkbox" data-e="another1" name="another" value="terrassa">
        var data_sd_value = $('body .row.row-page-prod').find(ThisFilterForFind).attr('data-e');

		if (data_sd_value == 'another1'){
			data_sd_value = 'terrassa';
		}

		if (data_sd_value == 'another2'){
			data_sd_value = 'kotelnaya';
		}

		if (data_sd_value == 'another3'){
			data_sd_value = 'mansarda';
		}

		if (data_sd_value == 'another4'){
			data_sd_value = 'secondlight';
		}
        console.log("☑☑ да - another / data_sd_value = " + data_sd_value);

		var FullAnother = data_sd_value+"="+data_sd_value
		console.log(FullSize);
    }

	// Если size
// 	if (data_sd_name !==  'price' || data_sd_name !==  'size'){
// 		var FullDataForLink = data_sd_name+"="+data_sd_value;
//     }


	if (data_sd_name !== 'another' || data_sd_name !==  'price' || data_sd_name !==  'size'){
		var FullDataForLink = data_sd_name+"="+data_sd_value;
	}
	if (data_sd_name == 'price') {
		var FullDataForLink = FullPrace;
    }
	if (data_sd_name == 'size') {
		var FullDataForLink = FullSize;
    }
	if (data_sd_name == 'another') {
		var FullDataForLink = FullAnother;
    } 
console.log('✅✅  FullDataForLink = ' + FullDataForLink);


//             var ParamNameRem = ThisFilterForFind;
//             // Данные выбранного фильтра
//             var ParamDataERem = ThisFilter;
//     // 		var FilterDataRem = "&"+ParamNameRem+""+ParamDataERem;
//             var FilterDataRem = "&"+ParamNameRem+"="+ThisFilterForFindVal;

//             console.log(FilterDataRem);

        });
    });
});
 
jQuery(document).ready(function($){

//https://ideisruba.rekunenko.pp.ua/proekty-iz-brusa/#FILTERprice_ot=1000000&price_do=1750000&room-numbers=4&mansarda=mansarda&

var ThisURL = window.location.href;

// var a=document.URL
location.hash = "FILTER";
// document.URL.replace('/#','');
window.location.href.hash = window.location.hash.split('#')[0];

// history.pushState('',document.title,window.location.pathname)
console.log(location.hash);
//  window.location.hash = window.history.pushState('', '/', window.location.pathname);

;
    $('.filters-show').on("DOMNodeInserted", function (event) {

        console.log('📘 Да! Было произведено обновление меню с выбранными фильтрами');

                // Отменяем повторение событий для меню 
                $(this).on('DOMNodeInserted', function(evt) {
                   evt.stopPropagation();
                // console.log("Повторный клик для .on был отменен");
                });

        $(this).each(function(){

//            var datae = $(this).find('.filter-item-accept').attr('data-e');
// 		console.log(datae);
                    var ThisFilter = $(this).find('.filter-item-accept').last().attr('data-e');
// 		console.log("ThisFilter = " + ThisFilter);
                    var ThisFilterForFind = "input[data-e=\""+ThisFilter+"\"]";
// console.log("ThisFilterForFind = " + ThisFilterForFind);

    // Узнаем имя 
    var data_sd_name = $('body .row.row-page-prod').find(ThisFilterForFind).attr('name').replace(/_/g,"-");
//     console.log("data_sd_name = " + data_sd_name);
	
	// Узнаем значение
	// 1 - Если НЕ выбран тип строения, размера или цены (у нас в нутри должны быть только цифры без текста )
	// .replace(/\D+/g,"") - Выризаем цифры из текста
    if (data_sd_name !== 'type-build' || data_sd_name !==  'price' || data_sd_name !==  'size'){
        var data_sd_value = $('body .row.row-page-prod').find(ThisFilterForFind).attr('data-e').replace(/\D+/g,"");
//         console.log("data_sd_value = " + data_sd_value);

	// 2 - Если выбран тип строения, размера или цены
    } 
	
	// Если type-build
	if (data_sd_name == 'type-build') {
        var data_sd_value = $('body .row.row-page-prod').find(ThisFilterForFind).attr('data-e');
//         console.log("✅ да - type-build / data_sd_value = " + data_sd_value);
    }

	// Если price
	if (data_sd_name == 'price') {
		// <input class="filter-c" type="checkbox" data-e="price1" name="price" data-min="0" data-max="500000">
        var data_sd_value = $('body .row.row-page-prod').find(ThisFilterForFind).attr('data-e');
//         console.log("✅ да - type-build / data_sd_value = " + data_sd_value);

		var data_sd_value_ot = $('body .row.row-page-prod').find(ThisFilterForFind).attr('data-min');
		var data_sd_value_do = $('body .row.row-page-prod').find(ThisFilterForFind).attr('data-max');

		var FullPrace = "price_ot="+data_sd_value_ot+"&price_do="+data_sd_value_do;
// 		console.log(FullPrace);
    }
	
	// Если size
	if (data_sd_name == 'size') {
		// <input class="filter-c" type="checkbox" data-e="price1" name="price" data-min="0" data-max="500000">
        var data_sd_value = $('body .row.row-page-prod').find(ThisFilterForFind).attr('data-e');
//         console.log("✅ да - type-build / data_sd_value = " + data_sd_value);

		var data_sd_value_ot = $('body .row.row-page-prod').find(ThisFilterForFind).attr('data-min');
		var data_sd_value_do = $('body .row.row-page-prod').find(ThisFilterForFind).attr('data-max');

		var FullSize = "size_ot="+data_sd_value_ot+"&size_do="+data_sd_value_do;
// 		console.log(FullSize);
    }

	if (data_sd_name == 'another') {
		// <input class="filter-c" type="checkbox" data-e="another1" name="another" value="terrassa">
        var data_sd_value = $('body .row.row-page-prod').find(ThisFilterForFind).attr('data-e');

		if (data_sd_value == 'another1'){
			data_sd_value = 'terrassa';
		}

		if (data_sd_value == 'another2'){
			data_sd_value = 'kotelnaya';
		}

		if (data_sd_value == 'another3'){
			data_sd_value = 'mansarda';
		}

		if (data_sd_value == 'another4'){
			data_sd_value = 'secondlight';
		}
//         console.log("☑☑ да - another / data_sd_value = " + data_sd_value);

		var FullAnother = data_sd_value+"="+data_sd_value;
// 		console.log(FullSize);
    }

	if (data_sd_name !== 'another' || data_sd_name !==  'price' || data_sd_name !==  'size'){
		var FullDataForLink = data_sd_name+"="+data_sd_value+"&";
	}
	if (data_sd_name == 'price') {
		var FullDataForLink = FullPrace+"&";
    }
	if (data_sd_name == 'size') {
		var FullDataForLink = FullSize+"&";
    }
	if (data_sd_name == 'another') {
		var FullDataForLink = FullAnother+"&";
    } 
console.log('✅✅  FullDataForLink = ' + FullDataForLink);

				// Текущий хеш
				var Hash = window.location.hash;

				var addURL = Hash + FullDataForLink;
				// И обновили хещ URL
				window.location.hash = addURL;

				console.log(window.location.hash);



 
		//🔴🔴🔴🔴🔴🔴🔴🔴🔴🔴🔴🔴🔴🔴🔴🔴🔴	
// 			//2️⃣
// 			// Текущий хеш
// 			var Hash = document.location.hash;
// 				console.log("🔗 Hash до = "+Hash);
			
// 			Делим хеш по данным фильра
//             // добавляем разделитель |
//             var HashRep = Hash.replace(/#FILTER-/g,"|#FILTER-");
//             console.log("🔎 HashRep = "+HashRep);
 
// 			var HashSplit = HashRep.split('|');
// 				console.log("✂ HashSplit = "+HashSplit);


// 			// Делаем проверку на наличие текущего фильтра в хеше
// 			if (jQuery.inArray(FullDataForLink, HashSplit)!='-1') {
// // 			if(this.checked && jQuery.inArray(addURL, HashSplit)!='-1') {
 
// 					console.log("1️⃣HashSplit До удаления = "+HashSplit);
// // 					console.log(HashSplit);
 
//               	    addURL = remove(HashSplit,addURL);
// 					addURL = addURL.toString().replace(/,/g,"");
// // 					addURL = addURL.replace(/,/g,"");
// 					console.log("2️⃣✂ HashSplit После удаления = "+addURL);
// 					console.log(HashSplit);
				
// 	            	console.log("😎✅ Текущий фильтр "+ FilterData +" Есть в текущем хеше"+HashSplit);
 
// 			} else {
 
// 				addURL = Hash + addURL;
// 				console.log("😎🔴 Текущий фильтр "+ FilterData +" Не есть в текущем хеше"+HashSplit);
 
// 			}
 
		//🔴🔴🔴🔴🔴🔴🔴🔴🔴🔴🔴🔴🔴🔴🔴🔴🔴


    });

});
 

$('.filters-show').on("click", ".filter-all-remove",function (event) {
	location.hash = "FILTER";
});

});
 jQuery(document).ready(function($){

//1️⃣ - Условие для определения URL и перехода на URL фильтрации
        var ThisURL = window.location.href;
        console.log(ThisURL);

// Если ссылка содержит слово фильтрации "#FILTER"
        if (ThisURL.indexOf("proekty-iz-brusa/&") >= 0 ){
            //     console.log("да в данном случае строка содепржит слово фильтрации");
            var NewURL = ThisURL.replace("proekty-iz-brusa/&","proekty-iz-brusa/?");
            // 	console.log("Новая ссылка для переадресации = "+NewURL);

            // window.location.href = NewURL;
            document.location.href = NewURL;
        }

        if (ThisURL.indexOf("#&") >= 0 ){
            //     console.log("да в данном случае строка содепржит слово фильтрации");
            var NewURL = ThisURL.replace("#&","&");
            // 	console.log("Новая ссылка для переадресации = "+NewURL);

            // window.location.href = NewURL;
            document.location.href = NewURL;
        }




//2️⃣ - Управление Хешем URL

        location.hash = "&";
// window.location.href.hash = window.location.hash.split('#')[0];



//3️⃣ - Обработка в случае добавления элементов на панель меню фильтрации
        /*
            $('.filters-show').on("DOMNodeInserted", function (event) {

                console.log('📘 Да! Было произведено обновление меню с выбранными фильтрами');

                        // Отменяем повторение событий для меню
                        $(this).on('DOMNodeInserted', function(evt) {
                           evt.stopPropagation();
                        // console.log("Повторный клик для .on был отменен");
                        });

                $(this).each(function(){

        // ================================================================================
            var ThisFilter = $(this).find('.filter-item-accept').last().attr('data-e');
        // 		console.log("ThisFilter = " + ThisFilter);
            var ThisFilterForFind = "input[data-e=\""+ThisFilter+"\"]";
        // console.log("ThisFilterForFind = " + ThisFilterForFind);

            // Узнаем имя
            var data_sd_name = $('body .row.row-page-prod').find(ThisFilterForFind).attr('name').replace(/_/g,"-");
        //     console.log("data_sd_name = " + data_sd_name);

            // Узнаем значение
            // 1 - Если НЕ выбран тип строения, размера или цены (у нас в нутри должны быть только цифры без текста )
            // .replace(/\D+/g,"") - Выризаем цифры из текста
            if (data_sd_name !== 'type-build' || data_sd_name !==  'price' || data_sd_name !==  'size'){
                var data_sd_value = $('body .row.row-page-prod').find(ThisFilterForFind).attr('data-e').replace(/\D+/g,"");
        //         console.log("data_sd_value = " + data_sd_value);

            // 2 - Если выбран тип строения, размера или цены
            }

            // Если type-build
            if (data_sd_name == 'type-build') {
                var data_sd_value = $('body .row.row-page-prod').find(ThisFilterForFind).attr('data-e');
        //         console.log("✅ да - type-build / data_sd_value = " + data_sd_value);
            }

            // Если price
            if (data_sd_name == 'price') {
                // <input class="filter-c" type="checkbox" data-e="price1" name="price" data-min="0" data-max="500000">
                var data_sd_value = $('body .row.row-page-prod').find(ThisFilterForFind).attr('data-e');
        //         console.log("✅ да - type-build / data_sd_value = " + data_sd_value);

                var data_sd_value_ot = $('body .row.row-page-prod').find(ThisFilterForFind).attr('data-min');
                var data_sd_value_do = $('body .row.row-page-prod').find(ThisFilterForFind).attr('data-max');

                var FullPrace = "price_ot="+data_sd_value_ot+"&price_do="+data_sd_value_do;
        // 		console.log(FullPrace);
            }

            // Если size
            if (data_sd_name == 'size') {
                // <input class="filter-c" type="checkbox" data-e="price1" name="price" data-min="0" data-max="500000">
                var data_sd_value = $('body .row.row-page-prod').find(ThisFilterForFind).attr('data-e');
        //         console.log("✅ да - type-build / data_sd_value = " + data_sd_value);

                var data_sd_value_ot = $('body .row.row-page-prod').find(ThisFilterForFind).attr('data-min');
                var data_sd_value_do = $('body .row.row-page-prod').find(ThisFilterForFind).attr('data-max');

                var FullSize = "size_ot="+data_sd_value_ot+"&size_do="+data_sd_value_do;
        // 		console.log(FullSize);
            }

            if (data_sd_name == 'another') {
                // <input class="filter-c" type="checkbox" data-e="another1" name="another" value="terrassa">
                var data_sd_value = $('body .row.row-page-prod').find(ThisFilterForFind).attr('data-e');

                if (data_sd_value == 'another1'){
                    data_sd_value = 'terrassa';
                }

                if (data_sd_value == 'another2'){
                    data_sd_value = 'kotelnaya';
                }

                if (data_sd_value == 'another3'){
                    data_sd_value = 'mansarda';
                }

                if (data_sd_value == 'another4'){
                    data_sd_value = 'secondlight';
                }
        //         console.log("☑☑ да - another / data_sd_value = " + data_sd_value);

                var FullAnother = data_sd_value+"="+data_sd_value;
        // 		console.log(FullSize);
            }

            if (data_sd_name !== 'another' || data_sd_name !==  'price' || data_sd_name !==  'size'){
                var FullDataForLink = data_sd_name+"="+data_sd_value+"&";
            }
            if (data_sd_name == 'price') {
                var FullDataForLink = FullPrace+"&";
            }
            if (data_sd_name == 'size') {
                var FullDataForLink = FullSize+"&";
            }
            if (data_sd_name == 'another') {
                var FullDataForLink = FullAnother+"&";
            }
        // ================================================================================
        console.log('✅✅  FullDataForLink = ' + FullDataForLink);

                        // Текущий хеш
                        var Hash = window.location.hash;

                        var addURL = Hash + FullDataForLink;
                        // И обновили хещ URL
                        window.location.hash = addURL;

                        console.log(window.location.hash);




            });

        });
        */

//4️⃣ - Очищаем Хеш в случае очистки на панели
        $('.filters-show').on("click", ".filter-all-remove",function (event) {
            location.hash = "&";
        });




//🔴🔴🔴🔴🔴🔴🔴🔴🔴🔴🔴🔴🔴🔴🔴🔴🔴
//5️⃣ - В случае удаления какого-то фильтра
// $('.filters-show').on("DOMNodeRemoved", function (event) {
        $('.filters-show').on("DOMSubtreeModified", function (event) {

// $(".filters-show .filter-item-accept").on("remove", function () {
// setTimeout(function(){

// $(".filters-show").bind("DOMNodeRemoved", function () {
            console.log("🧹 Да элементы были удалены");

// Узнаем сколько элементов осталось после удаления .size()
// var HowDivsAfterRemov = $(this).find('.filter-item-accept').size();
// console.log(HowDivsAfterRemov);

            var TMP = '';

            $(this).find('.filter-item-accept').each(function(){
// $('.filters-show').find('.filter-item-accept').each(function(){

//         var ThisFilter = $(this).attr('data-e');
//         console.log("🧹 - ThisFilter = "+ThisFilter);
//         var ThisFilterForFind = "input[data-e=\""+ThisFilter+"\"]";
//         console.log("🧹 - ThisFilter = "+ThisFilterForFind);
// ================================================================================
                var ThisFilter = $(this).attr('data-e');
// 		console.log("ThisFilter = " + ThisFilter);
                var ThisFilterForFind = "input[data-e=\""+ThisFilter+"\"]";
// console.log("ThisFilterForFind = " + ThisFilterForFind);

                // Узнаем имя
                var data_sd_name = $('body .row.row-page-prod').find(ThisFilterForFind).attr('name').replace(/_/g,"-");
//     console.log("data_sd_name = " + data_sd_name);

                // Узнаем значение
                // 1 - Если НЕ выбран тип строения, размера или цены (у нас в нутри должны быть только цифры без текста )
                // .replace(/\D+/g,"") - Выризаем цифры из текста
                if (data_sd_name !== 'type-build' || data_sd_name !==  'price' || data_sd_name !==  'size'){
                    var data_sd_value = $('body .row.row-page-prod').find(ThisFilterForFind).attr('data-e').replace(/\D+/g,"");
//         console.log("data_sd_value = " + data_sd_value);

                    // 2 - Если выбран тип строения, размера или цены
                }

                // Если type-build
                if (data_sd_name == 'type-build') {
                    var data_sd_value = $('body .row.row-page-prod').find(ThisFilterForFind).attr('data-e');
//         console.log("✅ да - type-build / data_sd_value = " + data_sd_value);
                }

                // Если price
                if (data_sd_name == 'price') {
                    // <input class="filter-c" type="checkbox" data-e="price1" name="price" data-min="0" data-max="500000">
                    var data_sd_value = $('body .row.row-page-prod').find(ThisFilterForFind).attr('data-e');
//         console.log("✅ да - type-build / data_sd_value = " + data_sd_value);

                    var data_sd_value_ot = $('body .row.row-page-prod').find(ThisFilterForFind).attr('data-min');
                    var data_sd_value_do = $('body .row.row-page-prod').find(ThisFilterForFind).attr('data-max');

                    var FullPrace = "price_ot="+data_sd_value_ot+"&price_do="+data_sd_value_do;
// 		console.log(FullPrace);
                }

                // Если size
                if (data_sd_name == 'size') {
                    // <input class="filter-c" type="checkbox" data-e="price1" name="price" data-min="0" data-max="500000">
                    var data_sd_value = $('body .row.row-page-prod').find(ThisFilterForFind).attr('data-e');
//         console.log("✅ да - type-build / data_sd_value = " + data_sd_value);

                    var data_sd_value_ot = $('body .row.row-page-prod').find(ThisFilterForFind).attr('data-min');
                    var data_sd_value_do = $('body .row.row-page-prod').find(ThisFilterForFind).attr('data-max');

                    var FullSize = "size_ot="+data_sd_value_ot+"&size_do="+data_sd_value_do;
// 		console.log(FullSize);
                }

                if (data_sd_name == 'another') {
                    // <input class="filter-c" type="checkbox" data-e="another1" name="another" value="terrassa">
                    var data_sd_value = $('body .row.row-page-prod').find(ThisFilterForFind).attr('data-e');

                    if (data_sd_value == 'another1'){
                        data_sd_value = 'terrassa';
                    }

                    if (data_sd_value == 'another2'){
                        data_sd_value = 'kotelnaya';
                    }

                    if (data_sd_value == 'another3'){
                        data_sd_value = 'mansarda';
                    }

                    if (data_sd_value == 'another4'){
                        data_sd_value = 'secondlight';
                    }
//         console.log("☑☑ да - another / data_sd_value = " + data_sd_value);

                    var FullAnother = data_sd_value+"="+data_sd_value;
// 		console.log(FullSize);
                }

                if (data_sd_name !== 'another' || data_sd_name !==  'price' || data_sd_name !==  'size'){
                    var FullDataForLink = data_sd_name+"="+data_sd_value+"&";
                }
                if (data_sd_name == 'price') {
                    var FullDataForLink = FullPrace+"&";
                }
                if (data_sd_name == 'size') {
                    var FullDataForLink = FullSize+"&";
                }
                if (data_sd_name == 'another') {
                    var FullDataForLink = FullAnother+"&";
                }
// ================================================================================
//🔴🔴🔴🔴🔴🔴🔴🔴🔴🔴🔴🔴🔴🔴🔴🔴🔴

                TMP = TMP+FullDataForLink;
                location.hash = "&" + TMP;
// location.hash = "FILTER";
                console.log("🧹 - TMP = "+TMP);

            });

// }, 2000);



        });











    });

    jQuery(document).ready(function($){

//1️⃣ - Условие для определения URL и перехода на URL фильтрации
        var ThisURL = window.location.href;
        console.log(ThisURL);

        var Path = document.location.pathname;

// Если ссылка содержит слово фильтрации "#FILTER"
//         if (ThisURL.indexOf("proekty-iz-brusa/&") >= 0 ){
//             //     console.log("да в данном случае строка содепржит слово фильтрации");
//             var NewURL = ThisURL.replace("proekty-iz-brusa/&","proekty-iz-brusa/?");
//             // 	console.log("Новая ссылка для переадресации = "+NewURL);

//             // window.location.href = NewURL;
//             document.location.href = NewURL;
//         }

//         if (ThisURL.indexOf("#&") >= 0 ){
//             //     console.log("да в данном случае строка содепржит слово фильтрации");
//             var NewURL = ThisURL.replace("#&","&");
//             // 	console.log("Новая ссылка для переадресации = "+NewURL);

//             // window.location.href = NewURL;
//             document.location.href = NewURL;
//         }




//2️⃣ - Управление Хешем URL

//         location.hash = "&";

// var Path = document.location.pathname;
// window.history.pushState('','',Path + "&");


// 	window.history.pushState('','',Path + "&" + TMP);
// window.location.href.hash = window.location.hash.split('#')[0];



//3️⃣ - Обработка в случае добавления элементов на панель меню фильтрации







//🔴🔴🔴🔴🔴🔴🔴🔴🔴🔴🔴🔴🔴🔴🔴🔴🔴
//5️⃣ - В случае удаления какого-то фильтра
// $('.filters-show').on("DOMNodeRemoved", function (event) {
        $('.filters-show').on("DOMSubtreeModified", function (event) {

// $(".filters-show .filter-item-accept").on("remove", function () {
// setTimeout(function(){

// $(".filters-show").bind("DOMNodeRemoved", function () {
            console.log("🧹 Да элементы были удалены");

// Узнаем сколько элементов осталось после удаления .size()
// var HowDivsAfterRemov = $(this).find('.filter-item-accept').size();
// console.log(HowDivsAfterRemov);

            var TMP = '';

            $(this).find('.filter-item-accept').each(function(){
// $('.filters-show').find('.filter-item-accept').each(function(){

//         var ThisFilter = $(this).attr('data-e');
//         console.log("🧹 - ThisFilter = "+ThisFilter);
//         var ThisFilterForFind = "input[data-e=\""+ThisFilter+"\"]";
//         console.log("🧹 - ThisFilter = "+ThisFilterForFind);
// ================================================================================
                var ThisFilter = $(this).attr('data-e');
// 		console.log("ThisFilter = " + ThisFilter);
                var ThisFilterForFind = "input[data-e=\""+ThisFilter+"\"]";
// console.log("ThisFilterForFind = " + ThisFilterForFind);

                // Узнаем имя
                var data_sd_name = $('body .row.row-page-prod').find(ThisFilterForFind).attr('name').replace(/_/g,"-");
//     console.log("data_sd_name = " + data_sd_name);

                // Узнаем значение
                // 1 - Если НЕ выбран тип строения, размера или цены (у нас в нутри должны быть только цифры без текста )
                // .replace(/\D+/g,"") - Выризаем цифры из текста
                if (data_sd_name !== 'type-build' || data_sd_name !==  'price' || data_sd_name !==  'size'){
                    var data_sd_value = $('body .row.row-page-prod').find(ThisFilterForFind).attr('data-e').replace(/\D+/g,"");
//         console.log("data_sd_value = " + data_sd_value);

                    // 2 - Если выбран тип строения, размера или цены
                }

                // Если type-build
                if (data_sd_name == 'type-build') {
                    var data_sd_value = $('body .row.row-page-prod').find(ThisFilterForFind).attr('data-e');
//         console.log("✅ да - type-build / data_sd_value = " + data_sd_value);
                }

                // Если price
                if (data_sd_name == 'price') {
                    // <input class="filter-c" type="checkbox" data-e="price1" name="price" data-min="0" data-max="500000">
                    var data_sd_value = $('body .row.row-page-prod').find(ThisFilterForFind).attr('data-e');
//         console.log("✅ да - type-build / data_sd_value = " + data_sd_value);

                    var data_sd_value_ot = $('body .row.row-page-prod').find(ThisFilterForFind).attr('data-min');
                    var data_sd_value_do = $('body .row.row-page-prod').find(ThisFilterForFind).attr('data-max');

                    var FullPrace = "price_ot="+data_sd_value_ot+"&price_do="+data_sd_value_do;
// 		console.log(FullPrace);
                }

                // Если size
                if (data_sd_name == 'size') {
                    // <input class="filter-c" type="checkbox" data-e="price1" name="price" data-min="0" data-max="500000">
                    var data_sd_value = $('body .row.row-page-prod').find(ThisFilterForFind).attr('data-e');
//         console.log("✅ да - type-build / data_sd_value = " + data_sd_value);

                    var data_sd_value_ot = $('body .row.row-page-prod').find(ThisFilterForFind).attr('data-min');
                    var data_sd_value_do = $('body .row.row-page-prod').find(ThisFilterForFind).attr('data-max');

                    var FullSize = "size_ot="+data_sd_value_ot+"&size_do="+data_sd_value_do;
// 		console.log(FullSize);
                }

                if (data_sd_name == 'another') {
                    // <input class="filter-c" type="checkbox" data-e="another1" name="another" value="terrassa">
                    var data_sd_value = $('body .row.row-page-prod').find(ThisFilterForFind).attr('data-e');

                    if (data_sd_value == 'another1'){
                        data_sd_value = 'terrassa';
                    }

                    if (data_sd_value == 'another2'){
                        data_sd_value = 'kotelnaya';
                    }

                    if (data_sd_value == 'another3'){
                        data_sd_value = 'mansarda';
                    }

                    if (data_sd_value == 'another4'){
                        data_sd_value = 'secondlight';
                    }
//         console.log("☑☑ да - another / data_sd_value = " + data_sd_value);

                    var FullAnother = data_sd_value+"="+data_sd_value;
// 		console.log(FullSize);
                }

                if (data_sd_name !== 'another' || data_sd_name !==  'price' || data_sd_name !==  'size'){
                    var FullDataForLink = data_sd_name+"="+data_sd_value+"&";
                }
                if (data_sd_name == 'price') {
                    var FullDataForLink = FullPrace+"&";
                }
                if (data_sd_name == 'size') {
                    var FullDataForLink = FullSize+"&";
                }
                if (data_sd_name == 'another') {
                    var FullDataForLink = FullAnother+"&";
                }
// ================================================================================
//🔴🔴🔴🔴🔴🔴🔴🔴🔴🔴🔴🔴🔴🔴🔴🔴🔴

                TMP = TMP+FullDataForLink;

                var TMPConsole = TMP+"🔴";
                console.log(TMPConsole);
//                 location.hash = "&" + TMP;
// Замена хеша

                console.log("🧹🧹🧹🧹🧹🧹🧹 Path = "+Path);

                window.history.pushState('','',Path + "&" + TMP);


// location.hash = "FILTER";
                console.log("🧹 - TMP = "+TMP);

            });

// }, 2000);



        });


//4️⃣ - Очищаем Хеш в случае очистки на панели
        $('.filters-show').on("click", ".filter-all-remove",function (event) {

            // location.hash = "&";
            console.log('🔴🔴🔴🔴🔴🔴🔴🔴🔴 Path = '+Path);
// 			var Path = document.location.pathname;
            window.history.pushState('','',Path + "&");
        });










    });
  jQuery(document).ready(function($){

//1️⃣ - Условие для определения URL и перехода на URL фильтрации
        var ThisURL = window.location.href;
        console.log(ThisURL);

        var Path = document.location.pathname;


//2️⃣ - Управление Хешем URL

//         location.hash = "&";

// var Path = document.location.pathname;
// window.history.pushState('','',Path + "&");


// 	window.history.pushState('','',Path + "&" + TMP);
// window.location.href.hash = window.location.hash.split('#')[0];



//3️⃣ - Обработка в случае добавления элементов на панель меню фильтрации


//🔴🔴🔴🔴🔴🔴🔴🔴🔴🔴🔴🔴🔴🔴🔴🔴🔴
//5️⃣ - В случае удаления какого-то фильтра
// $('.filters-show').on("DOMNodeRemoved", function (event) {
        $('.filters-show').on("DOMSubtreeModified", function (event) {


            var TMP = '';

            $(this).find('.filter-item-accept').each(function(){
// $('.filters-show').find('.filter-item-accept').each(function(){

//         var ThisFilter = $(this).attr('data-e');
//         console.log("🧹 - ThisFilter = "+ThisFilter);
//         var ThisFilterForFind = "input[data-e=\""+ThisFilter+"\"]";
//         console.log("🧹 - ThisFilter = "+ThisFilterForFind);
// ================================================================================
                var ThisFilter = $(this).attr('data-e');
// 		console.log("ThisFilter = " + ThisFilter);
                var ThisFilterForFind = "input[data-e=\""+ThisFilter+"\"]";
// console.log("ThisFilterForFind = " + ThisFilterForFind);

                // Узнаем имя
                var data_sd_name = $('body .row.row-page-prod').find(ThisFilterForFind).attr('name').replace(/_/g,"-");
//     console.log("data_sd_name = " + data_sd_name);

                // Узнаем значение
                // 1 - Если НЕ выбран тип строения, размера или цены (у нас в нутри должны быть только цифры без текста )
                // .replace(/\D+/g,"") - Выризаем цифры из текста
                if (data_sd_name !== 'type-build' || data_sd_name !==  'price' || data_sd_name !==  'size'){
                    var data_sd_value = $('body .row.row-page-prod').find(ThisFilterForFind).attr('data-e').replace(/\D+/g,"");
//         console.log("data_sd_value = " + data_sd_value);

                    // 2 - Если выбран тип строения, размера или цены
                }

                // Если type-build
                if (data_sd_name == 'type-build') {
                    var data_sd_value = $('body .row.row-page-prod').find(ThisFilterForFind).attr('data-e');
//         console.log("✅ да - type-build / data_sd_value = " + data_sd_value);
                }

                // Если price
                if (data_sd_name == 'price') {
                    // <input class="filter-c" type="checkbox" data-e="price1" name="price" data-min="0" data-max="500000">
                    var data_sd_value = $('body .row.row-page-prod').find(ThisFilterForFind).attr('data-e');
//         console.log("✅ да - type-build / data_sd_value = " + data_sd_value);

                    var data_sd_value_ot = $('body .row.row-page-prod').find(ThisFilterForFind).attr('data-min');
                    var data_sd_value_do = $('body .row.row-page-prod').find(ThisFilterForFind).attr('data-max');

                    var FullPrace = "price_ot="+data_sd_value_ot+"&price_do="+data_sd_value_do;
// 		console.log(FullPrace);
                }

                // Если size
                if (data_sd_name == 'size') {
                    // <input class="filter-c" type="checkbox" data-e="price1" name="price" data-min="0" data-max="500000">
                    var data_sd_value = $('body .row.row-page-prod').find(ThisFilterForFind).attr('data-e');
//         console.log("✅ да - type-build / data_sd_value = " + data_sd_value);

                    var data_sd_value_ot = $('body .row.row-page-prod').find(ThisFilterForFind).attr('data-min');
                    var data_sd_value_do = $('body .row.row-page-prod').find(ThisFilterForFind).attr('data-max');

                    var FullSize = "size_ot="+data_sd_value_ot+"&size_do="+data_sd_value_do;
// 		console.log(FullSize);
                }

                if (data_sd_name == 'another') {
                    // <input class="filter-c" type="checkbox" data-e="another1" name="another" value="terrassa">
                    var data_sd_value = $('body .row.row-page-prod').find(ThisFilterForFind).attr('data-e');

                    if (data_sd_value == 'another1'){
                        data_sd_value = 'terrassa';
                    }

                    if (data_sd_value == 'another2'){
                        data_sd_value = 'kotelnaya';
                    }

                    if (data_sd_value == 'another3'){
                        data_sd_value = 'mansarda';
                    }

                    if (data_sd_value == 'another4'){
                        data_sd_value = 'secondlight';
                    }
//         console.log("☑☑ да - another / data_sd_value = " + data_sd_value);

                    var FullAnother = data_sd_value+"="+data_sd_value;
// 		console.log(FullSize);
                }

                if (data_sd_name !== 'another' || data_sd_name !==  'price' || data_sd_name !==  'size'){
                    var FullDataForLink = data_sd_name+"="+data_sd_value+"&";
                }
                if (data_sd_name == 'price') {
                    var FullDataForLink = FullPrace+"&";
                }
                if (data_sd_name == 'size') {
                    var FullDataForLink = FullSize+"&";
                }
                if (data_sd_name == 'another') {
                    var FullDataForLink = FullAnother+"&";
                }
// ================================================================================
//🔴🔴🔴🔴🔴🔴🔴🔴🔴🔴🔴🔴🔴🔴🔴🔴🔴

                TMP = TMP+FullDataForLink;

                // var TMPConsole = TMP+"🔴";
                // console.log(TMPConsole);
//                 location.hash = "&" + TMP;
// Замена хеша

                console.log("🧹🧹🧹🧹🧹🧹🧹 Path = "+Path);

                window.history.pushState('','',Path + "?" + TMP);


// location.hash = "FILTER";
                console.log("🧹 - TMP = "+TMP);

            });

            // Удаление всех элементов в случае если кнопка удалена
            function explode(){
                if ($('body .filter-all-remove').length > 0){
                    console.log("👌👌👌👌👌👌👌👌 На месте");
                } //else {

                // if (!$('body .filter-all-remove').length){
                if ($('body .filter-all-remove').is(":hidden")){
                    console.log("👌👌🧹🧹🧹🧹🧹🧹🧹 Кнопка удалена 🔴🔴🔴🔴🔴");
                    // location.hash = "&";
                    console.log('🔴🔴🔴🔴🔴🔴🔴🔴🔴 Path = '+Path);

                    window.history.pushState('','',Path + "?");
                }

            }
            setTimeout(explode, 300);


        });


//4️⃣ - Очищаем окончание слага в случае очистки на панели
        $('.filters-show').on("click", ".filter-all-remove",function (event) {

            // location.hash = "&";
            console.log('🔴🔴🔴🔴🔴🔴🔴🔴🔴 Path = '+Path);
// 			var Path = document.location.pathname;
            window.history.pushState('','',Path + "?");
        });

    });
<?php



/**



 * Template name: Проекты из бревна



 */



	get_header(); ?>
	<style>
	@media (max-width: 1370px) {
	.hh-160 {
		height: 160px;
	}
	.hh-160 img {
		height: 100%
	}
	}
	@media (max-width: 550px) {
		.hh-160 img {
		display: none;
		/*height: auto;*/
	}
	.hh-160 {
		height: 30px;
	}
	.img-text-c {
		position: relative;
	}
	.subcategory-row {
		margin-top: 0;
	}
	.category-all-row {
		margin-top: 0;
	}
	.img-text-c {
		margin-bottom: 0;
	}
	.row.category-all-row , .row.subcategory-row {margin-bottom: 20px; display: flex;flex-direction: column;}
	.row.subcategory-row .cl-xs-4.col-md-12 {margin-bottom: 0;}
	.img-c.hh-160 {height: 0;}
	.card-underline-c{display: none;}
	.row.subcategory-row .cl-xs-4.col-md-12 a, .row.category-all-row .col-md-12 a {font-size: 18px;}
	.row.subcategory-row .card-underline-c {display: none;}
	.img-c.hh-160 img {width: 80px;;	}
	.subcategory-row div {margin-bottom: 20px;}
	span.current {font-size: 15px;}
	.breadcrumbs {margin-top: 0px}
	.page-title {display: none;}
	}

</style>


<div id="primary" class="content-area">

	<?php 

		$price1 = $_GET['price_ot'];

		$price2 = $_GET['price_do'];

		$size1 = $_GET['size_ot'];

		$size2 = $_GET['size_do'];

		$floors = $_GET['floors-numbers'];

		$terrassa = $_GET['terrassa'];

		$kotelnaya = $_GET['kotelnaya'];

		$mansarda = $_GET['mansarda'];

		$home = $_GET['home'];



		

	?>



	<main id="main" class="site-main projects-page">

		<div class="container">

		<div class="row">

				<div class="col-lg-12">

					<div class="title-medium">Типы строений</div>

				</div>

			</div>

			<div class="row subcategory-row mb30">

				<div class="col-xs-4 col-md-3">

					<a href="<?php echo get_site_url() . "/proekty-iz-brevna/?type-build=home"?>" class="card-c">

						<div class="img-c hh-160">

							<img src="<?php echo get_stylesheet_directory_uri() . '/img/brevnodoma.jpg'; ?>" alt="">

							<div class="img-text-c">Дома</div>

						</div>

						<div class="card-home card-underline-c <?php if($_GET['type-build'] === 'home'){echo 'card-underline-c-active';}?>">

							<span>Посмотреть все <i class="arrow-c right-c"></i></span>

						</div>

					</a>

				</div>

				<div class="col-xs-4 col-md-3">

					<a href="<?php echo get_site_url() . "/proekty-iz-brevna/?type-build=bathhouse"?>" class="card-c">

						<div class="img-c hh-160">

							<img src="<?php echo get_stylesheet_directory_uri() . '/img/brevnobani.jpg'; ?>" alt="">

							<div class="img-text-c">Бани</div>

						</div>

						<div class="card-bathhouse card-underline-c <?php if($_GET['type-build'] === 'bathhouse'){echo 'card-underline-c-active';}?>">

							<span>Посмотреть все <i class="arrow-c right-c"></i></span>

						</div>

					</a>

				</div>

				<div class="col-xs-4 col-md-3 mb30">

					<a href="<?php echo get_site_url() . "/proekty-iz-brevna/?type-build=arbor"?>" class="card-c">

						<div class="img-c hh-160">

							<img src="<?php echo get_stylesheet_directory_uri() . '/img/brevnobesedka.jpg'; ?>" alt="">

							<div class="img-text-c">Беседки</div>

						</div>

						<div class="card-arbor card-underline-c <?php if($_GET['type-build'] === 'arbor'){echo 'card-underline-c-active';}?>">

							<span>Посмотреть все <i class="arrow-c right-c"></i></span>

						</div>

					</a>

				</div>

			</div>

			<div class="row title-search">

				<div class="col-xs-12 col-md-8 flex-aic">

				<?php 

					if($_GET['type-build'] === 'arbor'){

						$titletext = 'беседок';

					}

					if($_GET['type-build'] === 'home'){

						$titletext = 'домов';

					}

					if($_GET['type-build'] === 'bathhouse'){

						$titletext = 'бань';

					} ?>

					<div class="title-medium">Все проекты <?php echo $titletext; ?> из рубленного и оцилиндрованного бревна</div>

				</div>

				<div class="col-xs-12 col-md-4 flex-aic search-block-c">

					<input type="text" class="small-text-inp" placeholder="поиск по названию проекта">	

				</div>

			</div>



			<div class="row">





                <div class="col-xs-12 col-md-8 flex-c filters-show" style="min-height:40px">
                    <?php

                    /**
                     * $_GET = TRUE for type_build
                     */

                    ?>
                    <?php if($_GET['type-build'] != ''){

                        if($_GET['type-build'] === 'arbor'){
                            $filtertext = 'Беседки';
                        }
                        if($_GET['type-build'] === 'home'){
                            $filtertext = 'Дома';
                        }
                        if($_GET['type-build'] === 'bathhouse'){
                            $filtertext = 'Бани';
                        }
                        ?>
                        <div class="filter-item-accept" data-e="<?php echo $_GET['type-build']?>"><?php echo 	$filtertext; ?></div>
                    <?php } ?>
                    <?php

                    /**
                     * $_GET = TRUE for price
                     */

                    ?>
                    <?php if($_GET['price_ot'] != ''){

                        if($_GET['price_ot'] === '0'){
                            $price_filtertext = 'до 500 тыс. руб.';
                            $price_datae = "price1";
                        }
                        if($_GET['price_ot'] === '500000'){
                            $price_filtertext = 'от 500 тыс. руб. - до 1 млн. руб.';
                            $price_datae = "price2";
                        }
                        if($_GET['price_ot'] === '1000000'){
                            $price_filtertext = 'от 1 млн. руб. - до 1,750 млн. руб.';
                            $price_datae = "price3";
                        }
                        if($_GET['price_ot'] === '1750000'){
                            $price_filtertext = 'от 1,750 млн. руб. - до 2,5 млн. руб.';
                            $price_datae = "price4";
                        }
                        if($_GET['price_ot'] === '2500000'){
                            $price_filtertext = 'от 2,5 млн. руб.';
                            $price_datae = "price5";
                        }
                        ?>
                        <div class="filter-item-accept" data-e="<?php echo $price_datae?>"><?php echo 	$price_filtertext; ?></div>
                    <?php } ?>
                    <?php
                    /**
                     * $_GET = TRUE for size
                     */

                    ?>
                    <?php if($_GET['size_ot'] != ''){

                        if($_GET['size_ot'] === '0'){
                            $size_filtertext = 'до 50 м2';
                            $size_datae = "size1";
                        }
                        if($_GET['size_ot'] === '50'){
                            $size_filtertext = 'от 50 до 75 м2';
                            $size_datae = "size2";
                        }
                        if($_GET['size_ot'] === '75'){
                            $size_filtertext = 'от 75 до 120 м2';
                            $size_datae = "size3";
                        }
                        if($_GET['size_ot'] === '120'){
                            $size_filtertext = 'от 120 до 200 м2';
                            $size_datae = "size4";
                        }
                        if($_GET['size_ot'] === '200'){
                            $size_filtertext = 'от 200 до 300 м2';
                            $size_datae = "size5";
                        }
                        if($_GET['size_ot'] === '300'){
                            $size_filtertext = 'от 300 до 400 м2';
                            $size_datae = "size5";
                        }
                        ?>
                        <div class="filter-item-accept" data-e="<?php echo $size_datae?>"><?php echo $size_filtertext; ?></div>
                    <?php } ?>
                    <?php
                    /**
                     * $_GET = TRUE for floors-numbers
                     */

                    ?>
                    <?php if($_GET['floors-numbers'] != ''){

                        if($_GET['floors-numbers'] === '1'){
                            $floors_numbers_filtertext = '1';
                            $floors_numbers_size_datae = "floors_numbers1";
                        }
                        if($_GET['floors-numbers'] === '2'){
                            $floors_numbers_filtertext = '2';
                            $floors_numbers_size_datae = "floors_numbers2";
                        }
                        ?>
                        <div class="filter-item-accept" data-e="<?php echo $floors_numbers_size_datae; ?>"><?php echo 	$floors_numbers_filtertext; ?></div>
                    <?php } ?>
                    <?php
                    /**
                     * $_GET = TRUE for room-numbers
                     */

                    ?>
                    <?php if($_GET['room-numbers'] != ''){

                        if($_GET['room-numbers'] === '1'){
                            $room_numbers_filtertext = '1';
                            $room_numbers_datae = "room_numbers1";
                        }
                        if($_GET['room-numbers'] === '2'){
                            $room_numbers_filtertext = '2';
                            $room_numbers_datae = "room_numbers2";
                        }
                        if($_GET['room-numbers'] === '3'){
                            $room_numbers_filtertext = '3';
                            $room_numbers_datae = "room_numbers3";
                        }
                        if($_GET['room-numbers'] === '4'){
                            $room_numbers_filtertext = '4';
                            $room_numbers_datae = "room_numbers4";
                        }
                        if($_GET['room-numbers'] === '5'){
                            $room_numbers_filtertext = '5';
                            $room_numbers_datae = "room_numbers5";
                        }
                        ?>
                        <div class="filter-item-accept" data-e="<?php echo $room_numbers_datae; ?>"><?php echo $room_numbers_filtertext; ?></div>
                    <?php } ?>
                    <?php
                    /**
                     * $_GET = TRUE for another
                     */

                    ?>
                    <?php if($_GET['terrassa'] != '' || $_GET['kotelnaya'] != '' || $_GET['mansarda'] != '' || $_GET['secondlight'] != ''){

                        if($_GET['terrassa'] === 'terrassa'){
                            $another_filtertext = 'С террасой';
                            $another_datae = "another1";
                        }
                        if($_GET['kotelnaya'] === 'kotelnaya'){
                            $another_filtertext = 'С котельной';
                            $another_datae = "another2";
                        }
                        if($_GET['mansarda'] === 'mansarda'){
                            $another_filtertext = 'С мансандрой';
                            $another_datae = "another3";
                        }
                        if($_GET['secondlight'] === 'secondlight') {
                            $another_filtertext = 'Со вторым
      светом';
                            $another_datae = "another4";
                        }
                        ?>
                        <div class="filter-item-accept" data-e="<?php echo $another_datae; ?>"><?php echo $another_filtertext; ?></div>
                    <?php } ?>


                    <?php

                    /**
                     * $_GET = TRUE Кнопка удаления пунктов меню фильтрации
                     */

                    ?>
                    <div class="filter-all-remove" <?php if($_GET != ''){echo 'style="display: block;"';}?>>Сбросить все</div>
                </div>


                <div class="col-xs-12 col-md-4 flex-c" style="min-height:40px">

					<div class="text-small-bold">Сортировать</div>

					<div class="dropdown-wrap">

						<div class="dropdown-value-active" data-value="totop">По умолчанию</div>

						<div class="dropdown-under">

							<div class="dropdown-value" data-value="totop">По умолчанию</div>

							<div class="dropdown-value" data-value="popularDESC"><span class="common-bold-text">По популярности</div>

							<div class="dropdown-value" data-value="sizeASC"><span class="common-bold-text">По площади: </span> от меньшей к большей</div>

							<div class="dropdown-value" data-value="sizeDESC"><span class="common-bold-text">По площади: </span> от большей к меньшей</div>

							<div class="dropdown-value" data-value="priceDESC"><span class="common-bold-text">По цене: </span> по убыванию</div>

							<div class="dropdown-value" data-value="priceASC"><span class="common-bold-text">По цене: </span> по возрастанию</div>

						</div>

						

					</div>

				</div>

			</div>

			<div class="mob-filters-button">

					<div class="mob-btn-c">Фильтры</div>

			</div>

			<div class="row row-page-prod">

				<div class="col-xs-12 col-md-3 filters-c">

					<div class="filter-item">

                        <script>
                            jQuery(document).ready(function($){

//1️⃣ - Условие для определения URL и перехода на URL фильтрации
                                var ThisURL = window.location.href;
                                console.log(ThisURL);

                                var Path = document.location.pathname;


//2️⃣ - Управление Хешем URL

//         location.hash = "&";

// var Path = document.location.pathname;
// window.history.pushState('','',Path + "&");


// 	window.history.pushState('','',Path + "&" + TMP);
// window.location.href.hash = window.location.hash.split('#')[0];



//3️⃣ - Обработка в случае добавления элементов на панель меню фильтрации


//🔴🔴🔴🔴🔴🔴🔴🔴🔴🔴🔴🔴🔴🔴🔴🔴🔴
//5️⃣ - В случае удаления какого-то фильтра
// $('.filters-show').on("DOMNodeRemoved", function (event) {
                                $('.filters-show').on("DOMSubtreeModified", function (event) {


                                    var TMP = '';

                                    $(this).find('.filter-item-accept').each(function(){
// $('.filters-show').find('.filter-item-accept').each(function(){

//         var ThisFilter = $(this).attr('data-e');
//         console.log("🧹 - ThisFilter = "+ThisFilter);
//         var ThisFilterForFind = "input[data-e=\""+ThisFilter+"\"]";
//         console.log("🧹 - ThisFilter = "+ThisFilterForFind);
// ================================================================================
                                        var ThisFilter = $(this).attr('data-e');
// 		console.log("ThisFilter = " + ThisFilter);
                                        var ThisFilterForFind = "input[data-e=\""+ThisFilter+"\"]";
// console.log("ThisFilterForFind = " + ThisFilterForFind);

                                        // Узнаем имя
                                        var data_sd_name = $('body .row.row-page-prod').find(ThisFilterForFind).attr('name').replace(/_/g,"-");
//     console.log("data_sd_name = " + data_sd_name);

                                        // Узнаем значение
                                        // 1 - Если НЕ выбран тип строения, размера или цены (у нас в нутри должны быть только цифры без текста )
                                        // .replace(/\D+/g,"") - Выризаем цифры из текста
                                        if (data_sd_name !== 'type-build' || data_sd_name !==  'price' || data_sd_name !==  'size'){
                                            var data_sd_value = $('body .row.row-page-prod').find(ThisFilterForFind).attr('data-e').replace(/\D+/g,"");
//         console.log("data_sd_value = " + data_sd_value);

                                            // 2 - Если выбран тип строения, размера или цены
                                        }

                                        // Если type-build
                                        if (data_sd_name == 'type-build') {
                                            var data_sd_value = $('body .row.row-page-prod').find(ThisFilterForFind).attr('data-e');
//         console.log("✅ да - type-build / data_sd_value = " + data_sd_value);
                                        }

                                        // Если price
                                        if (data_sd_name == 'price') {
                                            // <input class="filter-c" type="checkbox" data-e="price1" name="price" data-min="0" data-max="500000">
                                            var data_sd_value = $('body .row.row-page-prod').find(ThisFilterForFind).attr('data-e');
//         console.log("✅ да - type-build / data_sd_value = " + data_sd_value);

                                            var data_sd_value_ot = $('body .row.row-page-prod').find(ThisFilterForFind).attr('data-min');
                                            var data_sd_value_do = $('body .row.row-page-prod').find(ThisFilterForFind).attr('data-max');

                                            var FullPrace = "price_ot="+data_sd_value_ot+"&price_do="+data_sd_value_do;
// 		console.log(FullPrace);
                                        }

                                        // Если size
                                        if (data_sd_name == 'size') {
                                            // <input class="filter-c" type="checkbox" data-e="price1" name="price" data-min="0" data-max="500000">
                                            var data_sd_value = $('body .row.row-page-prod').find(ThisFilterForFind).attr('data-e');
//         console.log("✅ да - type-build / data_sd_value = " + data_sd_value);

                                            var data_sd_value_ot = $('body .row.row-page-prod').find(ThisFilterForFind).attr('data-min');
                                            var data_sd_value_do = $('body .row.row-page-prod').find(ThisFilterForFind).attr('data-max');

                                            var FullSize = "size_ot="+data_sd_value_ot+"&size_do="+data_sd_value_do;
// 		console.log(FullSize);
                                        }

                                        if (data_sd_name == 'another') {
                                            // <input class="filter-c" type="checkbox" data-e="another1" name="another" value="terrassa">
                                            var data_sd_value = $('body .row.row-page-prod').find(ThisFilterForFind).attr('data-e');

                                            if (data_sd_value == 'another1'){
                                                data_sd_value = 'terrassa';
                                            }

                                            if (data_sd_value == 'another2'){
                                                data_sd_value = 'kotelnaya';
                                            }

                                            if (data_sd_value == 'another3'){
                                                data_sd_value = 'mansarda';
                                            }

                                            if (data_sd_value == 'another4'){
                                                data_sd_value = 'secondlight';
                                            }
//         console.log("☑☑ да - another / data_sd_value = " + data_sd_value);

                                            var FullAnother = data_sd_value+"="+data_sd_value;
// 		console.log(FullSize);
                                        }

                                        if (data_sd_name !== 'another' || data_sd_name !==  'price' || data_sd_name !==  'size'){
                                            var FullDataForLink = data_sd_name+"="+data_sd_value+"&";
                                        }
                                        if (data_sd_name == 'price') {
                                            var FullDataForLink = FullPrace+"&";
                                        }
                                        if (data_sd_name == 'size') {
                                            var FullDataForLink = FullSize+"&";
                                        }
                                        if (data_sd_name == 'another') {
                                            var FullDataForLink = FullAnother+"&";
                                        }
// ================================================================================
//🔴🔴🔴🔴🔴🔴🔴🔴🔴🔴🔴🔴🔴🔴🔴🔴🔴

                                        TMP = TMP+FullDataForLink;

                                        // var TMPConsole = TMP+"🔴";
                                        // console.log(TMPConsole);
//                 location.hash = "&" + TMP;
// Замена хеша

                                        console.log("🧹🧹🧹🧹🧹🧹🧹 Path = "+Path);

                                        window.history.pushState('','',Path + "?" + TMP);


// location.hash = "FILTER";
                                        console.log("🧹 - TMP = "+TMP);

                                    });

                                    // Удаление всех элементов в случае если кнопка удалена
                                    function explode(){
                                        if ($('body .filter-all-remove').length > 0){
                                            console.log("👌👌👌👌👌👌👌👌 На месте");
                                        } //else {

                                        // if (!$('body .filter-all-remove').length){
                                        if ($('body .filter-all-remove').is(":hidden")){
                                            console.log("👌👌🧹🧹🧹🧹🧹🧹🧹 Кнопка удалена 🔴🔴🔴🔴🔴");
                                            // location.hash = "&";
                                            console.log('🔴🔴🔴🔴🔴🔴🔴🔴🔴 Path = '+Path);

                                            window.history.pushState('','',Path + "?");
                                        }

                                    }
                                    setTimeout(explode, 300);


                                });


//4️⃣ - Очищаем окончание слага в случае очистки на панели
                                $('.filters-show').on("click", ".filter-all-remove",function (event) {

                                    // location.hash = "&";
                                    console.log('🔴🔴🔴🔴🔴🔴🔴🔴🔴 Path = '+Path);
// 			var Path = document.location.pathname;
                                    window.history.pushState('','',Path + "?");
                                });

                            });
                        </script>

                        <?php
                        if($home === '1') {
                            $meta_query = array(
                                'relation' => 'AND',
                                array(
                                    'key' => 'material',
                                    'value' => 'brevno',
                                ));
                            if ($price1 !== null && $price2 !== null) {
                                array_push($meta_query, array(
                                    'key' => 'price',
                                    'value' => array($price1, $price2),
                                    'type' => 'numeric',
                                    'compare' => 'BETWEEN'
                                ));
                            }

                            if ($size1 !== '' && $size2 !== '') {
                                array_push($meta_query, array(
                                    'key' => 'size',
                                    'value' => array($size1, $size2),
                                    'type' => 'numeric',
                                    'compare' => 'BETWEEN'
                                ));
                            }

                            if ($floors !== '') {
                                array_push($meta_query, array(
                                    'key' => 'floors-numbers',
                                    'value' => $floors,
                                    'type' => 'numeric',
                                    'compare' => '='
                                ));
                            }

                            if ($terrassa !== null) {
                                array_push($meta_query, array(
                                    'key' => 'terrassa',
                                    'value' => $terrassa,
                                    'compare' => 'LIKE'
                                ));
                            }

                            if ($kotelnaya !== null) {
                                array_push($meta_query, array(
                                    'key' => 'kotelnaya',
                                    'value' => $kotelnaya,
                                    'compare' => 'LIKE'
                                ));
                            }
                            if ($mansarda !== null) {
                                array_push($meta_query, array(
                                    'key' => 'mansarda',
                                    'value' => $mansarda,
                                    'compare' => 'LIKE'
                                ));
                            }
                            // if($secondlight !== null){
                            // 	array_push($meta_query, array(
                            // 		'key' => 'secondlight',
                            // 		'value' => $secondlight,
                            // 		'compare' => 'LIKE'
                            // 	));
                            // }

                            $args = array(
                                'category_name' => 'proekty',
                                'meta_query' => $meta_query,
                                'meta_key' => 'totop',
                                'orderby' => 'meta_value',
                                'order' => 'DESC'
                            );
                        }

                        if (!empty($_GET['type-build']) || !empty($_GET['room-numbers']) || !empty($_GET['price_ot']) || !empty($_GET['price_do']) || !empty($_GET['size_ot']) || !empty($_GET['size_do']) || !empty($_GET['floors-numbers']) || !empty($_GET['terrassa']) || !empty($_GET['kotelnaya']) || !empty($_GET['mansarda']) ){


                            $meta_query = array(
                                'relation'		=> 'AND',
                                array(
                                    'key'   => 'material',
                                    'value' => 'brevno',
                                ));

                            // ===============================================
                            //                    if ($_GET){
//s('Да есть в правилах');
//   ✔                    $price1 = $_GET['price_ot'];
//   ✔                    $price2 = $_GET['price_do'];
//   ✔                    $size1 = $_GET['size_ot'];
//   ✔                    $size2 = $_GET['size_do'];
//   ✔                    $floors = $_GET['floors-numbers'];
//   ✔                    $terrassa = $_GET['terrassa'];
//   ✔                    $kotelnaya = $_GET['kotelnaya'];
//                        $mansarda = $_GET['mansarda'];
//                        $home = $_GET['home'];

                            // ===============================================
                            //?terrassa=terrassa
                            if(!empty($_GET['terrassa'])){
                                array_push($meta_query, array(
                                    'key' => 'terrassa',
                                    'value' => $_GET['terrassa'],
                                    'compare' => 'LIKE'
                                ));
                            }

                            // ===============================================
                            //?kotelnaya=kotelnaya
                            if(!empty($_GET['kotelnaya'])){
                                array_push($meta_query, array(
                                    'key' => 'kotelnaya',
                                    'value' => $_GET['kotelnaya'],
                                    'compare' => 'LIKE'
                                ));
                            }

                            // ===============================================
                            //?mansarda=mansarda
                            if(!empty($_GET['mansarda'])){
                                array_push($meta_query, array(
                                    'key' => 'mansarda',
                                    'value' => $_GET['mansarda'],
                                    'compare' => 'LIKE'
                                ));
                            }


                            // ===============================================
                            // ?type-build=home
                            // ?type-build=arbor
                            // ?type-build=bathhouse
                            if(!empty($_GET['type-build'])){
                                array_push($meta_query, array(
                                    'key' => 'type-build',
                                    'compare' => 'LIKE',
                                    'value' => $_GET['type-build']
                                ));
                            }


                            // ===============================================
                            //&room-numbers=1
                            //&room-numbers=2
                            //&room-numbers=3
                            //&room-numbers=4
                            //&room-numbers=5
                            if(!empty($_GET['room-numbers'])){
                                array_push($meta_query, array(
                                    'key' => 'room-numbers',
                                    'compare' => 'LIKE',
                                    'value' => $_GET['room-numbers']
                                ));
                            }
                            // ===============================================

                            //&floors-numbers=1
                            //&floors-numbers=2
                            if(!empty($_GET['floors-numbers'])){
                                array_push($meta_query, array(
                                    'key' => 'floors-numbers',
                                    'compare' => 'LIKE',
                                    'value' => $_GET['floors-numbers']
                                ));
                            }
                            // ===============================================
                            //
                            // до 500 тыс. руб.
                            // ?price_ot=0&price_do=500000
                            // от 500 тыс. руб. - до 1 млн. руб.
                            // ?price_ot=500000&price_do=1000000
                            // от 1 млн. руб. - до 1,750 млн. руб.
                            // ?price_ot=1000000&price_do=1750000
                            // от 1,750 млн. руб. - до 2,5 млн. руб.
                            // ?price_ot=1750000&price_do=2500000
                            // от 2,5 млн. руб.
                            // ?price_ot=2500000&price_do=99999999


                            if (!empty($_GET['price_ot'])){
                                $price1 =  (int)$_GET['price_ot'];
                            }
                            if (!empty($_GET['price_do'])){
                                $price2 =  (int)$_GET['price_do'];
                            }
                            if ($price1 !== null && $price2 !== null) {
                                array_push($meta_query, array(
                                    'key' => 'price',
                                    'value' => array($price1, $price2),
                                    'type' => 'numeric',
                                    'compare' => 'BETWEEN'
                                ));
                            }
                            // ===============================================
                            // до 50 м2
                            // ?size_ot=0&size_do=50
                            // от 50 до 75 м2
                            // ?size_ot=50&size_do=75
                            // от 75 до 120 м2
                            // ?size_ot=75&size_do=120
                            // от 120 до 200 м2
                            // ?size_ot=120&size_do=200
                            // от 200 до 300 м2
                            // ?size_ot=200&size_do=300
                            // от 300 до 400 м2
                            // ?size_ot=300&size_do=400


                            if (!empty($_GET['size_ot'])){
                                $size1 = (int)$_GET['size_ot'];
                            }
                            if (!empty($_GET['size_do'])){
                                $size2 = (int)$_GET['size_do'];
                            }


                            if ($size1 !== null && $size2 !== null) {
//                            s($_GET);
                                array_push($meta_query, array(
                                    'key' => 'size',
                                    'value' => array($size1, $size2),
                                    'type' => 'numeric',
                                    'compare' => 'BETWEEN'
                                ));
                            }
                            // ===============================================

                        }


                        $args = array(
                            'category_name' => 'proekty',
                            'meta_query' => $meta_query,
                            'meta_key' => 'totop',
                            'orderby'  => 'meta_value',
                            'order'    => 'DESC'
                        );
                        $f_typebuild1 = false;
                        $f_typebuild2 = false;
                        $f_typebuild3 = false;

                        $f_price1 = false;
                        $f_price2 = false;
                        $f_price3 = false;
                        $f_price4 = false;
                        $f_price5 = false;
                        $f_price6 = false;

                        $f_size1 = false;
                        $f_size2 = false;
                        $f_size3 = false;
                        $f_size4 = false;
                        $f_size5 = false;

                        $f_floors_number1 = false;
                        $f_floors_number2 = false;

                        $f_room_number1 = false;
                        $f_room_number2 = false;
                        $f_room_number3 = false;
                        $f_room_number4= false;
                        $f_room_number5= false;

                        $f_terrassa = false;
                        $f_kotelnaya = false;
                        $f_mansarda = false;
                        $f_secondlight = false;


                        $query = new WP_Query( $args );
                        if( $query->have_posts() ) {

                            while( $query->have_posts() ) {
                                $query->the_post();
                                //type-build
                                if(get_field('type-build') === 'home'){
                                    $f_typebuild1 = true;
                                }
                                if(get_field('type-build') === 'arbor'){
                                    $f_typebuild2 = true;
                                }
                                if(get_field('type-build') === 'bathhouse'){
                                    $f_typebuild3 = true;
                                }

                                //price
                                if(get_field( 'price' ) < 500000){
                                    $f_price1 = true;
                                }
                                if(get_field( 'price' ) > 500000 && get_field( 'price' ) < 1000000){
                                    $f_price2 = true;
                                }
                                if(get_field( 'price' ) > 1000000 && get_field( 'price' ) < 1750000){
                                    $f_price3 = true;
                                }
                                if(get_field( 'price' ) > 1750000 && get_field( 'price' ) < 2500000){
                                    $f_price4 = true;
                                }
                                if(get_field( 'price' ) > 2500000){
                                    $f_price5 = true;
                                }

                                //size
                                if(get_field( 'size' ) < 50){
                                    $f_size1 = true;
                                }
                                if(get_field( 'size' ) > 50 && get_field( 'size' ) < 75){
                                    $f_size2 = true;
                                }
                                if(get_field( 'size' ) > 75 && get_field( 'size' ) < 120){
                                    $f_size3 = true;
                                }
                                if(get_field( 'size' ) > 120 && get_field( 'size' ) < 200){
                                    $f_size4 = true;
                                }
                                if(get_field( 'size' ) > 200 && get_field( 'size' ) < 300){
                                    $f_size5 = true;
                                }
                                if(get_field( 'size' ) > 300 && get_field( 'size' ) < 400){
                                    $f_size6 = true;
                                }

                                //floors_number
                                if(get_field( 'floors-numbers' ) == 1){
                                    $f_floors_number1 = true;
                                }
                                if(get_field( 'floors-numbers' ) == 2){
                                    $f_floors_number2 = true;
                                }

                                //room_number
                                if(get_field( 'room-numbers' ) == 1){
                                    $f_room_number1 = true;
                                }
                                if(get_field( 'room-numbers' ) == 2){
                                    $f_room_number2 = true;
                                }
                                if(get_field( 'room-numbers' ) == 3){
                                    $f_room_number3 = true;
                                }
                                if(get_field( 'room-numbers' ) == 4){
                                    $f_room_number4 = true;
                                }
                                if(get_field( 'room-numbers' ) == 5){
                                    $f_room_number5 = true;
                                }
                                //another
                                if (get_field('terrassa')[0] === 'terrassa'){
                                    $f_terrassa = true;
                                }
                                if (get_field('kotelnaya')[0] === 'kotelnaya'){
                                    $f_kotelnaya = true;
                                }
                                if (get_field('mansarda')[0] === 'mansarda'){
                                    $f_mansarda = true;
                                }
                                if (get_field('secondlight')[0] === 'secondlight'){
                                    $f_secondlight = true;
                                }
                            }
                        }
                        ?>
                        <div class="filter-name">Тип строения</div>
                        <?php

                        /**
                         * Левое меню с фильтрацией
                         * 🗃
                         */

                        ?>
                        <div class="filter-values flex-column">
                            <?php if($_GET['type-build'] === 'home' || $_GET['type-build'] == ''){ ?>
                                <label><input class="filter-c" type="checkbox" name="type_build" data-e="home" value="home" <?php if($_GET['type-build'] === 'home'){echo  "checked=\"checked\"";} ?> data-sd-name"type-build" data-sd-value="checked">Дома</label>
                            <?php } ?>
                            <?php if($_GET['type-build'] === 'arbor' || $_GET['type-build'] == ''){ ?>
                                <label><input class="filter-c" type="checkbox" name="type_build" data-e="arbor" value="arbor" <?php if($_GET['type-build'] === 'home'){echo  "checked=\"checked\"";} ?> data-sd-name"type-build" data-sd-value="arbor">Беседки</label>
                            <?php } ?>
                            <?php if($_GET['type-build'] === 'bathhouse' || $_GET['type-build'] == ''){ ?>
                                <label><input class="filter-c" type="checkbox" name="type_build" data-e="bathhouse" value="bathhouse" <?php if($_GET['type-build'] === 'bathhouse'){echo  "checked=\"checked\"";} ?> data-sd-name"type-build" data-sd-value="bathhouse">Бани</label>
                            <?php } ?>
                        </div>
                    </div>
                    <div class="filter-item">
                        <div class="filter-name">Цена</div>
                        <div class="filter-values flex-column">
                            <!--                                price_ot=500000&price_do=1000000-->
                            <!--                                $price1, $price2-->
                            <?php if($f_price1){ ?>
                                <label><input class="filter-c" type="checkbox" name="price" data-e="price1" data-min="0" data-max="500000" <?php if($_GET['price_ot'] === '0' && $_GET['price_do'] === '500000' ){echo  "checked=\"checked\"";} ?> data-sd-name"price" data-sd-ot"0" data-sd-do"500000">до 500 тыс. руб.</label>
                            <?php } ?>
                            <?php if($f_price2){ ?>
                                <label><input class="filter-c" type="checkbox" name="price" data-e="price2" data-min="500000" data-max="1000000" <?php if($_GET['price_ot'] === '500000' && $_GET['price_do'] === '1000000' ){echo  "checked=\"checked\"";} ?> data-sd-name"price" data-sd-ot"500000" data-sd-do"1000000">от 500 тыс. руб. - до 1 млн. руб.</label>
                            <?php } ?>
                            <?php if($f_price3){ ?>
                                <label><input class="filter-c" type="checkbox" name="price" data-e="price3" data-min="1000000" data-max="1750000" <?php if($_GET['price_ot'] === '1000000' && $_GET['price_do'] === '1750000' ){echo  "checked=\"checked\"";} ?> data-sd-name"price" data-sd-ot"1000000" data-sd-do"1750000">от 1 млн. руб. - до 1,750 млн. руб.</label>
                            <?php } ?>
                            <?php if($f_price4){ ?>
                                <label><input class="filter-c" type="checkbox" name="price" data-e="price4" data-min="1750000" data-max="2500000" <?php if($_GET['price_ot'] === '1750000' && $_GET['price_do'] === '2500000' ){echo  "checked=\"checked\"";} ?> data-sd-name"price" data-sd-ot"1750000" data-sd-do"2500000">от 1,750 млн. руб. - до 2,5 млн. руб.</label>
                            <?php } ?>
                            <?php if($f_price5){ ?>
                                <label><input class="filter-c" type="checkbox" name="price" data-e="price5" data-min="2500000" data-max="99999999" <?php if($_GET['price_ot'] === '2500000' && $_GET['price_do'] === '99999999' ){echo  "checked=\"checked\"";} ?> data-sd-name"price" data-sd-ot"2500000" data-sd-do"99999999">от 2,5 млн. руб.</label>
                            <?php } ?>
                        </div>
                    </div>
                    <div class="filter-item">
                        <div class="filter-name">Общая площадь</div>
                        <div class="filter-values flex-column">
                            <!--                                ?size_ot=0&size_do=50-->
                            <?php if($f_size1){ ?>
                                <label><input class="filter-c" type="checkbox" name="size" data-e="size1" data-min="0" data-max="50" <?php if($_GET['size_ot'] === '0' && $_GET['size_do'] === '50' ){echo  "checked=\"checked\"";} ?> data-sd-name"size" data-sd-ot"0" data-sd-do"50">до 50 м2</label>
                            <?php } ?>
                            <?php if($f_size2){ ?>
                                <label><input class="filter-c" type="checkbox" name="size" data-e="size2" data-min="50" data-max="75" <?php if($_GET['size_ot'] === '50' && $_GET['size_do'] === '75' ){echo  "checked=\"checked\"";} ?> data-sd-name"size" data-sd-ot"50" data-sd-do"75">от 50 до 75 м2</label>
                            <?php } ?>
                            <?php if($f_size3){ ?>
                                <label><input class="filter-c" type="checkbox" name="size" data-e="size3" data-min="75" data-max="120" <?php if($_GET['size_ot'] === '75' && $_GET['size_do'] === '120' ){echo  "checked=\"checked\"";} ?> data-sd-name"size" data-sd-ot"75" data-sd-do"120">от 75 до 120 м2</label>
                            <?php } ?>
                            <?php if($f_size4){ ?>
                                <label><input class="filter-c" type="checkbox" name="size" data-e="size4" data-min="120" data-max="200" <?php if($_GET['size_ot'] === '120' && $_GET['size_do'] === '200' ){echo  "checked=\"checked\"";} ?> data-sd-name"size" data-sd-ot"120" data-sd-do"200">от 120 до 200 м2</label>
                            <?php } ?>
                            <?php if($f_size5){ ?>
                                <label><input class="filter-c" type="checkbox" name="size" data-e="size5" data-min="200" data-max="300" <?php if($_GET['size_ot'] === '200' && $_GET['size_do'] === '300' ){echo  "checked=\"checked\"";} ?> data-sd-name"size" data-sd-ot"200" data-sd-do"300">от 200 до 300 м2</label>
                            <?php } ?>
                            <?php if($f_size6){ ?>
                                <label><input class="filter-c" type="checkbox" name="size" data-e="size6" data-min="300" data-max="400" <?php if($_GET['size_ot'] === '300' && $_GET['size_do'] === '400' ){echo  "checked=\"checked\"";} ?> data-sd-name"size" data-sd-ot"300" data-sd-do"400">от 300 до 400 м2</label>
                            <?php } ?>
                        </div>
                    </div>
                    <div class="filter-item">
                        <div class="filter-name">Количество этажей</div>
                        <div class="filter-values flex-column">
                            <!--                                //&floors-numbers=1-->
                            <?php if($f_floors_number1){ ?>
                                <label><input class="filter-c" type="checkbox" data-e="floors_numbers1" name="floors_numbers" value="1" <?php if($_GET['floors-numbers'] === '1'){echo  "checked=\"checked\"";} ?> data-sd-name"floors-numbers" data-sd-value="1">1</label>
                            <?php } ?>
                            <?php if($f_floors_number2){ ?>
                                <label><input class="filter-c" type="checkbox" data-e="floors_numbers2" name="floors_numbers" value="2" <?php if($_GET['floors-numbers'] === '2'){echo  "checked=\"checked\"";} ?> data-sd-name"floors-numbers" data-sd-value="2">2</label>
                            <?php } ?>
                        </div>
                    </div>
                    <div class="filter-item">
                        <div class="filter-name">Количество комнат</div>
                        <div class="filter-values flex-column">
                            <?php if($f_room_number1){ ?>
                                <label><input class="filter-c" type="checkbox" data-e="room_numbers1" name="room_numbers" value="1" <?php if($_GET['room-numbers'] === '1'){echo  "checked=\"checked\"";} ?> data-sd-name"room-numbers" data-sd-value="1">1</label>
                            <?php } ?>
                            <?php if($f_room_number2){ ?>
                                <label><input class="filter-c" type="checkbox" data-e="room_numbers2" name="room_numbers" value="2" <?php if($_GET['room-numbers'] === '2'){echo  "checked=\"checked\"";} ?> data-sd-name"room-numbers" data-sd-value="2">2</label>
                            <?php } ?>
                            <?php if($f_room_number3){ ?>
                                <label><input class="filter-c" type="checkbox" data-e="room_numbers3" name="room_numbers" value="3" <?php if($_GET['room-numbers'] === '3'){echo  "checked=\"checked\"";} ?> data-sd-name"room-numbers" data-sd-value="3">3</label>
                            <?php } ?>
                            <?php if($f_room_number4){ ?>
                                <label><input class="filter-c" type="checkbox" data-e="room_numbers4" name="room_numbers" value="4" <?php if($_GET['room-numbers'] === '4'){echo  "checked=\"checked\"";} ?> data-sd-name"room-numbers" data-sd-value="4">4</label>
                            <?php } ?>
                            <?php if($f_room_number5){ ?>
                                <label><input class="filter-c" type="checkbox" data-e="room_numbers5" name="room_numbers" value="5" <?php if($_GET['room-numbers'] === '5'){echo  "checked=\"checked\"";} ?> data-sd-name"room-numbers" data-sd-value="5">5</label>
                            <?php } ?>
                        </div>
                    </div>
                    <div class="filter-item">
                        <div class="filter-name">Дополнительно</div>
                        <div class="filter-values flex-column">
                            <?php if($f_terrassa){ ?>
                                <label><input class="filter-c" type="checkbox" data-e="another1" name="another" value="terrassa" <?php if($_GET['terrassa'] === 'terrassa'){echo  "checked=\"checked\"";} ?> data-sd-name"terrassa" data-sd-value="terrassa">С террасой</label>
                            <?php } ?>
                            <?php if($f_kotelnaya){ ?>
                                <label><input class="filter-c" type="checkbox" data-e="another2" name="another" value="kotelnaya" <?php if($_GET['kotelnaya'] === 'kotelnaya'){echo  "checked=\"checked\"";} ?> data-sd-name"kotelnaya" data-sd-value="kotelnaya">С котельной</label>
                            <?php } ?>
                            <?php 	if($f_mansarda){ ?>
                                <label><input class="filter-c" type="checkbox" data-e="another3" name="another" value="mansarda" <?php if($_GET['mansarda'] === 'mansarda'){echo  "checked=\"checked\"";} ?> data-sd-name"mansarda" data-sd-value="mansarda">С мансандрой</label>
                            <?php } ?>
                            <?php 	if($f_secondlight){ ?>
                                <label><input class="filter-c" type="checkbox" data-e="another4" name="another" value="secondlight" <?php if($_GET['secondlight'] === 'secondlight'){echo  "checked=\"checked\"";} ?> data-sd-name"secondlight" data-sd-value="secondlight">Со вторым светом</label>
                            <?php } ?>
                        </div>
                    </div>

                </div>

				

				<div class="col-xs-12 col-md-9 products-c">

					<?php 



						$query = new WP_Query( $args );

							$paged = (get_query_var('page')) ? get_query_var('page') : 1;?>

					<script type='text/javascript'>

						var maxppages = <?php echo ceil($query->found_posts / $query->post_count) ?>;

					</script>

					<div class="row row-product">

						<?php	$count_pages = ceil($query->found_posts / $query->post_count);

							if ( $query->have_posts() ) {

								while ( $query->have_posts() ) {

									$query->the_post();?>

						<div class="col-xs-12 col-md-4">

							<a href="<?php the_permalink() ?>" class="order-link" data-id="<?php echo get_the_ID(); ?>">

								<div class="order-item">

									<div class="img-box">

										<?php if(has_post_thumbnail()) : ?>

										<?php the_post_thumbnail('project-main',array( 'alt' => get_the_title() )); ?>

										<?php else : ?>

										<img src="<?php echo get_template_directory_uri() ?>/img/placeholder.jpg" alt="placeholder">

										<?php endif; ?>

										<?php if(get_field('totop')) : ?>

										<div class="top">

											<?php the_field('totop') ?>

										</div>

										<?php endif; ?>

										<div class="favorite-c"><img src="<?php echo get_template_directory_uri()?>/img/favorite.svg" alt=""></div>

										<div class="title">

											<?php the_title() ?>

										</div>

									</div>

									<div class="info-box">

										<figure>

											<div class="order-tr">

												<span>жил. пл.</span>

												<p>

													<?php echo get_field( 'live-area' ); ?> м<sup>2</sup></p>

											</div>

											<div class="order-tr">

												<span>общ. пл.</span>

												<p>

													<?php echo get_field( 'size' ); ?> м<sup>2</sup></p>

											</div>

											<div class="order-tr">

												<span>кол.комнат</span>

												<p>

													<?php echo get_field( 'room-numbers' ); ?>

												</p>

											</div>

										</figure>

										<div class="price">

											Цена сегодня

											<span><span class="summa">

													<?php echo get_field( 'price' ); ?></span><i> ₽</i></span>

										</div>

									</div>

								</div>

							</a>

						</div>

						<?php }

							}



							wp_reset_postdata();

							?>



					</div>

				

				</div>



			</div>

			<div class="row">

						<div class="col-lg-push-3 col-lg-9 flex-c jcc">

							<div class="pagination-block-c flex-c">

							<nav aria-label=...>

								<ul class="pagination">

									<!-- <li id="previous-page"><a href="javascript:void(0)" aria-label=Previous><span aria-hidden=true>&laquo;</span></a></li> -->

								</ul>

							</nav>

								<!-- <button type="button" class="pagination-item-btn pagination-item-prev"><i class="arrow-c left-c"></i></button> -->



								<!-- <input type="button" class="pagination-item pagination-item-active" value="1">

								<input type="button" class="pagination-item" value="2">

								<input type="button" class="pagination-item" value="3"> -->



								<!-- <button type="button" class="pagination-item-btn pagination-item-next"><i class="arrow-c right-c"></i></button> -->

							</div>

						</div>

					</div>			

			<div class="dont-find-proj-section">



				<div class="row">

					<div class="col-sm-4">

						<div class="title">Не нашли нужного проекта?</div>

						<div class="subtitle">Присылайте свой чертеж для бесплатного проектирования и рассчета сметы</div>

						<a href="#send-drawing-popup" class="btn-accent middle popup-with-move-anim">Прислать чертеж</a>

					</div>

					<div class="col-sm-8">

						<div class="img-box">

							<img src="<?php echo get_template_directory_uri() ?>/img/dont-find-project-bg.jpg" alt="">

						</div>

					</div>

				</div>



			</div>



			<div class="triggers-section">



				<div class="row">

					<div class="col-xs-12 col-sm-12">

						<div class="section-title-box">

							<h3 class="section-title">Дополнительные выгоды</h3>

						</div>

					</div>

				</div>

				<div class="triggers">

					<div class="row">

						<div class="col-xs-12 col-sm-4 col-md-2">

							<div class="trigger wow fadeInDown">

								<div class="img-box"><i class="icon-shield"></i></div>

								<div class="description">Гарантия до 10 лет</div>

							</div>

						</div>

						<div class="col-xs-12 col-sm-4 col-md-2">

							<div class="trigger wow fadeInDown" data-wow-delay="0.1s">

								<div class="img-box"><i class="icon-list-ok"></i></div>

								<div class="description">Работаем строго по утвержденной смете</div>

							</div>

						</div>

						<div class="col-xs-12 col-sm-4 col-md-2">

							<div class="trigger wow fadeInDown" data-wow-delay="0.2s">

								<div class="img-box"><i class="icon-worker"></i></div>

								<div class="description">Бесплатный вызов специалиста на участок</div>

							</div>

						</div>

						<div class="col-xs-12 col-sm-4 col-md-2">

							<div class="trigger wow fadeInDown" data-wow-delay="0.3s">

								<div class="img-box"><i class="icon-hand-r"></i></div>

								<div class="description">Поэтапная оплата</div>

							</div>

						</div>

						<div class="col-xs-12 col-sm-4 col-md-2">

							<div class="trigger wow fadeInDown" data-wow-delay="0.4s">

								<div class="img-box"><i class="icon-telega"></i></div>

								<div class="description">Возможность строительства в кредит</div>

							</div>

						</div>

						<div class="col-xs-12 col-sm-4 col-md-2">

							<div class="trigger wow fadeInDown" data-wow-delay="0.5s">

								<div class="img-box"><i class="icon-magnifier"></i></div>

								<div class="description">Контроль качества на каждом этапе</div>

							</div>

						</div>

					</div>

				</div>





			</div>

			<div class="catalog-text">

				<?php the_content(); ?>

			</div>

		</div>

	</main>

</div>

<?php

get_sidebar();

	get_footer();
<?php

/**

 * Template name: Проекты из бруса

 */

get_header(); ?>
    <!-- 	<style>
            @media (min-width: 1370px) {
            .card-c{
                height: 160px;
            }
            .img-c img {
                height: 106px;
            }
            .projects-page {
                margin: 15px 0 0;
            }
            .mb15 {
                margin-bottom: 15px;
            }
        }
        </style> -->
    <style>
        @media (max-width: 1370px) {
            .hh-160 {
                height: 160px;
            }
            .hh-160 img {
                height: 100%
            }
        }
        @media (max-width: 550px) {
            .hh-160 img {
                display: none;
                /*height: auto;*/
            }
            .hh-160 {
                height: 30px;
            }
            .img-text-c {
                position: relative;
            }
            .subcategory-row {
                margin-top: 0;
            }
            .category-all-row {
                margin-top: 0;
            }
            .img-text-c {
                margin-bottom: 0;
            }
            .row.category-all-row , .row.subcategory-row {margin-bottom: 20px; display: flex;flex-direction: column;}
            .row.subcategory-row .cl-xs-4.col-md-12 {margin-bottom: 0;}
            .img-c.hh-160 {height: 0;}
            .card-underline-c{display: none;}
            .row.subcategory-row .cl-xs-4.col-md-12 a, .row.category-all-row .col-md-12 a {font-size: 18px;}
            .row.subcategory-row .card-underline-c {display: none;}
            .img-c.hh-160 img {width: 80px;;	}
            .subcategory-row div {margin-bottom: 20px;}
            span.current {font-size: 15px;}
            .breadcrumbs {margin-top: 0px}
            .page-title {display: none;}
        }

    </style>
    <div id="primary" class="content-area">
        <?php
        $price1 = $_GET['price_ot'];
        $price2 = $_GET['price_do'];
        $size1 = $_GET['size_ot'];
        $size2 = $_GET['size_do'];
        $floors = $_GET['floors-numbers'];
        $terrassa = $_GET['terrassa'];
        $kotelnaya = $_GET['kotelnaya'];
        $mansarda = $_GET['mansarda'];
        $home = $_GET['home'];
        ?>
        <main id="main" class="site-main projects-page">
            <div class="container">
                <div class="row">
                    <div class="col-lg-12">
                        <div class="title-medium">Типы строений</div>
                    </div>
                </div>
                <div class="row subcategory-row mb15">
                    <div class="col-xs-4 col-md-3 mb30">
                        <a href="<?php echo get_site_url() . "/proekty-iz-brusa/?type-build=home"?>" class="card-c">
                            <div class="img-c hh-160">
                                <img src="<?php echo get_stylesheet_directory_uri() . '/img/brusdoma.jpg'; ?>" alt="">
                                <div class="img-text-c">Дома</div>
                            </div>
                            <div class="card-home card-underline-c <?php if($_GET['type-build'] === 'home'){echo 'card-underline-c-active';}?>">
                                <span>Посмотреть все <i class="arrow-c right-c"></i></span>
                            </div>
                        </a>
                    </div>
                    <div class="col-xs-4 col-md-3 mb30">
                        <a href="<?php echo get_site_url() . "/proekty-iz-brusa/?type-build=bathhouse"?>" class="card-c">
                            <div class="img-c hh-160">
                                <img src="<?php echo get_stylesheet_directory_uri() . '/img/brusbani.jpg'; ?>" alt="">
                                <div class="img-text-c">Бани</div>
                            </div>
                            <div class="card-bathhouse card-underline-c <?php if($_GET['type-build'] === 'bathhouse'){echo 'card-underline-c-active';}?>">
                                <span>Посмотреть все <i class="arrow-c right-c"></i></span>
                            </div>
                        </a>
                    </div>
                    <div class="col-xs-4 col-md-3 mb30">
                        <a href="<?php echo get_site_url() . "/proekty-iz-brusa/?type-build=arbor"?>" class="card-c">
                            <div class="img-c hh-160">
                                <img src="<?php echo get_stylesheet_directory_uri() . '/img/brusbesedka.jpg'; ?>" alt="">
                                <div class="img-text-c">Беседки</div>
                            </div>
                            <div class="card-arbor card-underline-c <?php if($_GET['type-build'] === 'arbor'){echo 'card-underline-c-active';}?>">
                                <span>Посмотреть все <i class="arrow-c right-c"></i></span>
                            </div>
                        </a>
                    </div>
                </div>
                <div class="row title-search">
                    <div class="col-xs-12 col-md-8 flex-aic">
                        <?php
                        if($_GET['type-build'] === 'arbor'){
                            $titletext = 'беседок';
                        }
                        if($_GET['type-build'] === 'home'){
                            $titletext = 'домов';
                        }
                        if($_GET['type-build'] === 'bathhouse'){
                            $titletext = 'бань';
                        } ?>
                        <div class="title-medium">Все проекты <?php echo $titletext; ?> из профилированного и клееного бруса</div>
                    </div>
                    <div class="col-xs-12 col-md-4 flex-aic search-block-c">
                        <input type="text" class="small-text-inp" placeholder="поиск по названию проекта">
                    </div>
                </div>

                <div class="row">


                    <div class="col-xs-12 col-md-8 flex-c filters-show" style="min-height:40px">
                        <?php

                        /**
                         * $_GET = TRUE for type_build
                         */

                        ?>
                        <?php if($_GET['type-build'] != ''){

                            if($_GET['type-build'] === 'arbor'){
                                $filtertext = 'Беседки';
                            }
                            if($_GET['type-build'] === 'home'){
                                $filtertext = 'Дома';
                            }
                            if($_GET['type-build'] === 'bathhouse'){
                                $filtertext = 'Бани';
                            }
                            ?>
                            <div class="filter-item-accept" data-e="<?php echo $_GET['type-build']?>"><?php echo 	$filtertext; ?></div>
                        <?php } ?>
                        <?php

                        /**
                         * $_GET = TRUE for price
                         */

                        ?>
                        <?php if($_GET['price_ot'] != ''){

                            if($_GET['price_ot'] === '0'){
                                $price_filtertext = 'до 500 тыс. руб.';
                                $price_datae = "price1";
                            }
                            if($_GET['price_ot'] === '500000'){
                                $price_filtertext = 'от 500 тыс. руб. - до 1 млн. руб.';
                                $price_datae = "price2";
                            }
                            if($_GET['price_ot'] === '1000000'){
                                $price_filtertext = 'от 1 млн. руб. - до 1,750 млн. руб.';
                                $price_datae = "price3";
                            }
                            if($_GET['price_ot'] === '1750000'){
                                $price_filtertext = 'от 1,750 млн. руб. - до 2,5 млн. руб.';
                                $price_datae = "price4";
                            }
                            if($_GET['price_ot'] === '2500000'){
                                $price_filtertext = 'от 2,5 млн. руб.';
                                $price_datae = "price5";
                            }
                            ?>
                            <div class="filter-item-accept" data-e="<?php echo $price_datae?>"><?php echo 	$price_filtertext; ?></div>
                        <?php } ?>
                        <?php
                        /**
                        * $_GET = TRUE for size
                        */

                        ?>
                        <?php if($_GET['size_ot'] != ''){

                            if($_GET['size_ot'] === '0'){
                                $size_filtertext = 'до 50 м2';
                                $size_datae = "size1";
                            }
                            if($_GET['size_ot'] === '50'){
                                $size_filtertext = 'от 50 до 75 м2';
                                $size_datae = "size2";
                            }
                            if($_GET['size_ot'] === '75'){
                                $size_filtertext = 'от 75 до 120 м2';
                                $size_datae = "size3";
                            }
                            if($_GET['size_ot'] === '120'){
                                $size_filtertext = 'от 120 до 200 м2';
                                $size_datae = "size4";
                            }
                            if($_GET['size_ot'] === '200'){
                                $size_filtertext = 'от 200 до 300 м2';
                                $size_datae = "size5";
                            }
                            if($_GET['size_ot'] === '300'){
                                $size_filtertext = 'от 300 до 400 м2';
                                $size_datae = "size5";
                            }
                            ?>
                            <div class="filter-item-accept" data-e="<?php echo $size_datae?>"><?php echo $size_filtertext; ?></div>
                        <?php } ?>
                        <?php
                        /**
                        * $_GET = TRUE for floors-numbers
                        */

                        ?>
                        <?php if($_GET['floors-numbers'] != ''){

                            if($_GET['floors-numbers'] === '1'){
                                $floors_numbers_filtertext = '1';
                                $floors_numbers_size_datae = "floors_numbers1";
                            }
                            if($_GET['floors-numbers'] === '2'){
                                $floors_numbers_filtertext = '2';
                                $floors_numbers_size_datae = "floors_numbers2";
                            }
                            ?>
                            <div class="filter-item-accept" data-e="<?php echo $floors_numbers_size_datae; ?>"><?php echo 	$floors_numbers_filtertext; ?></div>
                        <?php } ?>
                        <?php
                        /**
                         * $_GET = TRUE for room-numbers
                         */

                        ?>
                        <?php if($_GET['room-numbers'] != ''){

                            if($_GET['room-numbers'] === '1'){
                                $room_numbers_filtertext = '1';
                                $room_numbers_datae = "room_numbers1";
                            }
                            if($_GET['room-numbers'] === '2'){
                                $room_numbers_filtertext = '2';
                                $room_numbers_datae = "room_numbers2";
                            }
                            if($_GET['room-numbers'] === '3'){
                                $room_numbers_filtertext = '3';
                                $room_numbers_datae = "room_numbers3";
                            }
                            if($_GET['room-numbers'] === '4'){
                                $room_numbers_filtertext = '4';
                                $room_numbers_datae = "room_numbers4";
                            }
                            if($_GET['room-numbers'] === '5'){
                                $room_numbers_filtertext = '5';
                                $room_numbers_datae = "room_numbers5";
                            }
                            ?>
                            <div class="filter-item-accept" data-e="<?php echo $room_numbers_datae; ?>"><?php echo $room_numbers_filtertext; ?></div>
                        <?php } ?>
                        <?php
                        /**
                         * $_GET = TRUE for another
                         */

                        ?>
                        <?php if($_GET['terrassa'] != '' || $_GET['kotelnaya'] != '' || $_GET['mansarda'] != '' || $_GET['secondlight'] != ''){

                            if($_GET['terrassa'] === 'terrassa'){
                                $another_filtertext = 'С террасой';
                                $another_datae = "another1";
                            }
                            if($_GET['kotelnaya'] === 'kotelnaya'){
                                $another_filtertext = 'С котельной';
                                $another_datae = "another2";
                            }
                            if($_GET['mansarda'] === 'mansarda'){
                                $another_filtertext = 'С мансандрой';
                                $another_datae = "another3";
                            }
                            if($_GET['secondlight'] === 'secondlight') {
                                $another_filtertext = 'Со вторым
      светом';
                                $another_datae = "another4";
                            }
                            ?>
                            <div class="filter-item-accept" data-e="<?php echo $another_datae; ?>"><?php echo $another_filtertext; ?></div>
                        <?php } ?>


                        <?php

                        /**
                         * $_GET = TRUE Кнопка удаления пунктов меню фильтрации
                         */

                        ?>
                        <div class="filter-all-remove" <?php if($_GET != ''){echo 'style="display: block;"';}?>>Сбросить все</div>
                    </div>
                    <div class="col-xs-12 col-md-4 flex-c" style="min-height:40px">
                        <div class="text-small-bold">Сортировать</div>
                        <div class="dropdown-wrap">
                            <div class="dropdown-value-active" data-value="totop">По умолчанию</div>
                            <div class="dropdown-under">
                                <div class="dropdown-value" data-value="totop">По умолчанию</div>
                                <div class="dropdown-value" data-value="popularDESC"><span class="common-bold-text">По популярности</div>
                                <div class="dropdown-value" data-value="sizeASC"><span class="common-bold-text">По площади: </span> от меньшей к большей</div>
                                <div class="dropdown-value" data-value="sizeDESC"><span class="common-bold-text">По площади: </span> от большей к меньшей</div>
                                <div class="dropdown-value" data-value="priceDESC"><span class="common-bold-text">По цене: </span> по убыванию</div>
                                <div class="dropdown-value" data-value="priceASC"><span class="common-bold-text">По цене: </span> по возрастанию</div>
                            </div>

                        </div>
                    </div>
                </div>
                <div class="mob-filters-button">
                    <div class="mob-btn-c">Фильтры</div>
                </div>
                <div class="row row-page-prod">
                    <div class="col-xs-12 col-md-3 filters-c">
                        <div class="filter-item">

<script>
    jQuery(document).ready(function($){

//1️⃣ - Условие для определения URL и перехода на URL фильтрации
        var ThisURL = window.location.href;
        console.log(ThisURL);

        var Path = document.location.pathname;


//2️⃣ - Управление Хешем URL

//         location.hash = "&";

// var Path = document.location.pathname;
// window.history.pushState('','',Path + "&");


// 	window.history.pushState('','',Path + "&" + TMP);
// window.location.href.hash = window.location.hash.split('#')[0];



//3️⃣ - Обработка в случае добавления элементов на панель меню фильтрации


//🔴🔴🔴🔴🔴🔴🔴🔴🔴🔴🔴🔴🔴🔴🔴🔴🔴
//5️⃣ - В случае удаления какого-то фильтра
// $('.filters-show').on("DOMNodeRemoved", function (event) {
        $('.filters-show').on("DOMSubtreeModified", function (event) {


            var TMP = '';

            $(this).find('.filter-item-accept').each(function(){
// $('.filters-show').find('.filter-item-accept').each(function(){

//         var ThisFilter = $(this).attr('data-e');
//         console.log("🧹 - ThisFilter = "+ThisFilter);
//         var ThisFilterForFind = "input[data-e=\""+ThisFilter+"\"]";
//         console.log("🧹 - ThisFilter = "+ThisFilterForFind);
// ================================================================================
                var ThisFilter = $(this).attr('data-e');
// 		console.log("ThisFilter = " + ThisFilter);
                var ThisFilterForFind = "input[data-e=\""+ThisFilter+"\"]";
// console.log("ThisFilterForFind = " + ThisFilterForFind);

                // Узнаем имя
                var data_sd_name = $('body .row.row-page-prod').find(ThisFilterForFind).attr('name').replace(/_/g,"-");
//     console.log("data_sd_name = " + data_sd_name);

                // Узнаем значение
                // 1 - Если НЕ выбран тип строения, размера или цены (у нас в нутри должны быть только цифры без текста )
                // .replace(/\D+/g,"") - Выризаем цифры из текста
                if (data_sd_name !== 'type-build' || data_sd_name !==  'price' || data_sd_name !==  'size'){
                    var data_sd_value = $('body .row.row-page-prod').find(ThisFilterForFind).attr('data-e').replace(/\D+/g,"");
//         console.log("data_sd_value = " + data_sd_value);

                    // 2 - Если выбран тип строения, размера или цены
                }

                // Если type-build
                if (data_sd_name == 'type-build') {
                    var data_sd_value = $('body .row.row-page-prod').find(ThisFilterForFind).attr('data-e');
//         console.log("✅ да - type-build / data_sd_value = " + data_sd_value);
                }

                // Если price
                if (data_sd_name == 'price') {
                    // <input class="filter-c" type="checkbox" data-e="price1" name="price" data-min="0" data-max="500000">
                    var data_sd_value = $('body .row.row-page-prod').find(ThisFilterForFind).attr('data-e');
//         console.log("✅ да - type-build / data_sd_value = " + data_sd_value);

                    var data_sd_value_ot = $('body .row.row-page-prod').find(ThisFilterForFind).attr('data-min');
                    var data_sd_value_do = $('body .row.row-page-prod').find(ThisFilterForFind).attr('data-max');

                    var FullPrace = "price_ot="+data_sd_value_ot+"&price_do="+data_sd_value_do;
// 		console.log(FullPrace);
                }

                // Если size
                if (data_sd_name == 'size') {
                    // <input class="filter-c" type="checkbox" data-e="price1" name="price" data-min="0" data-max="500000">
                    var data_sd_value = $('body .row.row-page-prod').find(ThisFilterForFind).attr('data-e');
//         console.log("✅ да - type-build / data_sd_value = " + data_sd_value);

                    var data_sd_value_ot = $('body .row.row-page-prod').find(ThisFilterForFind).attr('data-min');
                    var data_sd_value_do = $('body .row.row-page-prod').find(ThisFilterForFind).attr('data-max');

                    var FullSize = "size_ot="+data_sd_value_ot+"&size_do="+data_sd_value_do;
// 		console.log(FullSize);
                }

                if (data_sd_name == 'another') {
                    // <input class="filter-c" type="checkbox" data-e="another1" name="another" value="terrassa">
                    var data_sd_value = $('body .row.row-page-prod').find(ThisFilterForFind).attr('data-e');

                    if (data_sd_value == 'another1'){
                        data_sd_value = 'terrassa';
                    }

                    if (data_sd_value == 'another2'){
                        data_sd_value = 'kotelnaya';
                    }

                    if (data_sd_value == 'another3'){
                        data_sd_value = 'mansarda';
                    }

                    if (data_sd_value == 'another4'){
                        data_sd_value = 'secondlight';
                    }
//         console.log("☑☑ да - another / data_sd_value = " + data_sd_value);

                    var FullAnother = data_sd_value+"="+data_sd_value;
// 		console.log(FullSize);
                }

                if (data_sd_name !== 'another' || data_sd_name !==  'price' || data_sd_name !==  'size'){
                    var FullDataForLink = data_sd_name+"="+data_sd_value+"&";
                }
                if (data_sd_name == 'price') {
                    var FullDataForLink = FullPrace+"&";
                }
                if (data_sd_name == 'size') {
                    var FullDataForLink = FullSize+"&";
                }
                if (data_sd_name == 'another') {
                    var FullDataForLink = FullAnother+"&";
                }
// ================================================================================
//🔴🔴🔴🔴🔴🔴🔴🔴🔴🔴🔴🔴🔴🔴🔴🔴🔴

                TMP = TMP+FullDataForLink;

                // var TMPConsole = TMP+"🔴";
                // console.log(TMPConsole);
//                 location.hash = "&" + TMP;
// Замена хеша

                console.log("🧹🧹🧹🧹🧹🧹🧹 Path = "+Path);

                window.history.pushState('','',Path + "?" + TMP);


// location.hash = "FILTER";
                console.log("🧹 - TMP = "+TMP);

            });

            // Удаление всех элементов в случае если кнопка удалена
            function explode(){
                if ($('body .filter-all-remove').length > 0){
                    console.log("👌👌👌👌👌👌👌👌 На месте");
                } //else {

                // if (!$('body .filter-all-remove').length){
                if ($('body .filter-all-remove').is(":hidden")){
                    console.log("👌👌🧹🧹🧹🧹🧹🧹🧹 Кнопка удалена 🔴🔴🔴🔴🔴");
                    // location.hash = "&";
                    console.log('🔴🔴🔴🔴🔴🔴🔴🔴🔴 Path = '+Path);

                    window.history.pushState('','',Path + "?");
                }

            }
            setTimeout(explode, 300);


        });


//4️⃣ - Очищаем окончание слага в случае очистки на панели
        $('.filters-show').on("click", ".filter-all-remove",function (event) {

            // location.hash = "&";
            console.log('🔴🔴🔴🔴🔴🔴🔴🔴🔴 Path = '+Path);
// 			var Path = document.location.pathname;
            window.history.pushState('','',Path + "?");
        });

    });
</script>

                            <?php
                            if($home === '1') {
                                $meta_query = array(
                                    'relation' => 'AND',
                                    array(
                                        'key' => 'material',
                                        'value' => 'brus',
                                    ));
                                if ($price1 !== null && $price2 !== null) {
                                    array_push($meta_query, array(
                                        'key' => 'price',
                                        'value' => array($price1, $price2),
                                        'type' => 'numeric',
                                        'compare' => 'BETWEEN'
                                    ));
                                }

                                if ($size1 !== '' && $size2 !== '') {
                                    array_push($meta_query, array(
                                        'key' => 'size',
                                        'value' => array($size1, $size2),
                                        'type' => 'numeric',
                                        'compare' => 'BETWEEN'
                                    ));
                                }

                                if ($floors !== '') {
                                    array_push($meta_query, array(
                                        'key' => 'floors-numbers',
                                        'value' => $floors,
                                        'type' => 'numeric',
                                        'compare' => '='
                                    ));
                                }

                                if ($terrassa !== null) {
                                    array_push($meta_query, array(
                                        'key' => 'terrassa',
                                        'value' => $terrassa,
                                        'compare' => 'LIKE'
                                    ));
                                }

                                if ($kotelnaya !== null) {
                                    array_push($meta_query, array(
                                        'key' => 'kotelnaya',
                                        'value' => $kotelnaya,
                                        'compare' => 'LIKE'
                                    ));
                                }
                                if ($mansarda !== null) {
                                    array_push($meta_query, array(
                                        'key' => 'mansarda',
                                        'value' => $mansarda,
                                        'compare' => 'LIKE'
                                    ));
                                }
                                // if($secondlight !== null){
                                // 	array_push($meta_query, array(
                                // 		'key' => 'secondlight',
                                // 		'value' => $secondlight,
                                // 		'compare' => 'LIKE'
                                // 	));
                                // }

                                $args = array(
                                    'category_name' => 'proekty',
                                    'meta_query' => $meta_query,
                                    'meta_key' => 'totop',
                                    'orderby' => 'meta_value',
                                    'order' => 'DESC'
                                );
                            }

if (!empty($_GET['type-build']) || !empty($_GET['room-numbers']) || !empty($_GET['price_ot']) || !empty($_GET['price_do']) || !empty($_GET['size_ot']) || !empty($_GET['size_do']) || !empty($_GET['floors-numbers']) || !empty($_GET['terrassa']) || !empty($_GET['kotelnaya']) || !empty($_GET['mansarda']) ){


                        $meta_query = array(
                            'relation'		=> 'AND',
                            array(
                                'key'   => 'material',
                                'value' => 'brus',
                            ));

                        // ===============================================
    //                    if ($_GET){
//s('Да есть в правилах');
//   ✔                    $price1 = $_GET['price_ot'];
//   ✔                    $price2 = $_GET['price_do'];
//   ✔                    $size1 = $_GET['size_ot'];
//   ✔                    $size2 = $_GET['size_do'];
//   ✔                    $floors = $_GET['floors-numbers'];
//   ✔                    $terrassa = $_GET['terrassa'];
//   ✔                    $kotelnaya = $_GET['kotelnaya'];
//                        $mansarda = $_GET['mansarda'];
//                        $home = $_GET['home'];

                        // ===============================================
                        //?terrassa=terrassa
                        if(!empty($_GET['terrassa'])){
                            array_push($meta_query, array(
                                'key' => 'terrassa',
                                'value' => $_GET['terrassa'],
                                'compare' => 'LIKE'
                            ));
                        }

                        // ===============================================
                        //?kotelnaya=kotelnaya
                        if(!empty($_GET['kotelnaya'])){
                            array_push($meta_query, array(
                                'key' => 'kotelnaya',
                                'value' => $_GET['kotelnaya'],
                                'compare' => 'LIKE'
                            ));
                        }

                        // ===============================================
                        //?mansarda=mansarda
                        if(!empty($_GET['mansarda'])){
                            array_push($meta_query, array(
                                'key' => 'mansarda',
                                'value' => $_GET['mansarda'],
                                'compare' => 'LIKE'
                            ));
                        }


                        // ===============================================
                        // ?type-build=home
                        // ?type-build=arbor
                        // ?type-build=bathhouse
                        if(!empty($_GET['type-build'])){
                            array_push($meta_query, array(
                                'key' => 'type-build',
                                'compare' => 'LIKE',
                                'value' => $_GET['type-build']
                            ));
                        }


                        // ===============================================
                        //&room-numbers=1
                        //&room-numbers=2
                        //&room-numbers=3
                        //&room-numbers=4
                        //&room-numbers=5
                        if(!empty($_GET['room-numbers'])){
                            array_push($meta_query, array(
                                'key' => 'room-numbers',
                                'compare' => 'LIKE',
                                'value' => $_GET['room-numbers']
                            ));
                        }
                        // ===============================================

                        //&floors-numbers=1
                        //&floors-numbers=2
                        if(!empty($_GET['floors-numbers'])){
                            array_push($meta_query, array(
                                'key' => 'floors-numbers',
                                'compare' => 'LIKE',
                                'value' => $_GET['floors-numbers']
                            ));
                        }
                        // ===============================================
    //
                        // до 500 тыс. руб.
                        // ?price_ot=0&price_do=500000
                        // от 500 тыс. руб. - до 1 млн. руб.
                        // ?price_ot=500000&price_do=1000000
                        // от 1 млн. руб. - до 1,750 млн. руб.
                        // ?price_ot=1000000&price_do=1750000
                        // от 1,750 млн. руб. - до 2,5 млн. руб.
                        // ?price_ot=1750000&price_do=2500000
                        // от 2,5 млн. руб.
                        // ?price_ot=2500000&price_do=99999999


                        if (!empty($_GET['price_ot'])){
                            $price1 =  (int)$_GET['price_ot'];
                        }
                        if (!empty($_GET['price_do'])){
                            $price2 =  (int)$_GET['price_do'];
                        }
                        if ($price1 !== null && $price2 !== null) {
                            array_push($meta_query, array(
                                'key' => 'price',
                                'value' => array($price1, $price2),
                                'type' => 'numeric',
                                'compare' => 'BETWEEN'
                            ));
                        }
                        // ===============================================
                        // до 50 м2
                        // ?size_ot=0&size_do=50
                        // от 50 до 75 м2
                        // ?size_ot=50&size_do=75
                        // от 75 до 120 м2
                        // ?size_ot=75&size_do=120
                        // от 120 до 200 м2
                        // ?size_ot=120&size_do=200
                        // от 200 до 300 м2
                        // ?size_ot=200&size_do=300
                        // от 300 до 400 м2
                        // ?size_ot=300&size_do=400


                        if (!empty($_GET['size_ot'])){
                            $size1 = (int)$_GET['size_ot'];
                        }
                        if (!empty($_GET['size_do'])){
                            $size2 = (int)$_GET['size_do'];
                        }


                        if ($size1 !== null && $size2 !== null) {
//                            s($_GET);
                            array_push($meta_query, array(
                                'key' => 'size',
                                'value' => array($size1, $size2),
                                'type' => 'numeric',
                                'compare' => 'BETWEEN'
                            ));
                        }
                        // ===============================================

                    }


                            $args = array(
                                'category_name' => 'proekty',
                                'meta_query' => $meta_query,
                                'meta_key' => 'totop',
                                'orderby'  => 'meta_value',
                                'order'    => 'DESC'
                            );
                            $f_typebuild1 = false;
                            $f_typebuild2 = false;
                            $f_typebuild3 = false;

                            $f_price1 = false;
                            $f_price2 = false;
                            $f_price3 = false;
                            $f_price4 = false;
                            $f_price5 = false;
                            $f_price6 = false;

                            $f_size1 = false;
                            $f_size2 = false;
                            $f_size3 = false;
                            $f_size4 = false;
                            $f_size5 = false;

                            $f_floors_number1 = false;
                            $f_floors_number2 = false;

                            $f_room_number1 = false;
                            $f_room_number2 = false;
                            $f_room_number3 = false;
                            $f_room_number4= false;
                            $f_room_number5= false;

                            $f_terrassa = false;
                            $f_kotelnaya = false;
                            $f_mansarda = false;
                            $f_secondlight = false;


                            $query = new WP_Query( $args );
                            if( $query->have_posts() ) {

                                while( $query->have_posts() ) {
                                    $query->the_post();
                                    //type-build
                                    if(get_field('type-build') === 'home'){
                                        $f_typebuild1 = true;
                                    }
                                    if(get_field('type-build') === 'arbor'){
                                        $f_typebuild2 = true;
                                    }
                                    if(get_field('type-build') === 'bathhouse'){
                                        $f_typebuild3 = true;
                                    }

                                    //price
                                    if(get_field( 'price' ) < 500000){
                                        $f_price1 = true;
                                    }
                                    if(get_field( 'price' ) > 500000 && get_field( 'price' ) < 1000000){
                                        $f_price2 = true;
                                    }
                                    if(get_field( 'price' ) > 1000000 && get_field( 'price' ) < 1750000){
                                        $f_price3 = true;
                                    }
                                    if(get_field( 'price' ) > 1750000 && get_field( 'price' ) < 2500000){
                                        $f_price4 = true;
                                    }
                                    if(get_field( 'price' ) > 2500000){
                                        $f_price5 = true;
                                    }

                                    //size
                                    if(get_field( 'size' ) < 50){
                                        $f_size1 = true;
                                    }
                                    if(get_field( 'size' ) > 50 && get_field( 'size' ) < 75){
                                        $f_size2 = true;
                                    }
                                    if(get_field( 'size' ) > 75 && get_field( 'size' ) < 120){
                                        $f_size3 = true;
                                    }
                                    if(get_field( 'size' ) > 120 && get_field( 'size' ) < 200){
                                        $f_size4 = true;
                                    }
                                    if(get_field( 'size' ) > 200 && get_field( 'size' ) < 300){
                                        $f_size5 = true;
                                    }
                                    if(get_field( 'size' ) > 300 && get_field( 'size' ) < 400){
                                        $f_size6 = true;
                                    }

                                    //floors_number
                                    if(get_field( 'floors-numbers' ) == 1){
                                        $f_floors_number1 = true;
                                    }
                                    if(get_field( 'floors-numbers' ) == 2){
                                        $f_floors_number2 = true;
                                    }

                                    //room_number
                                    if(get_field( 'room-numbers' ) == 1){
                                        $f_room_number1 = true;
                                    }
                                    if(get_field( 'room-numbers' ) == 2){
                                        $f_room_number2 = true;
                                    }
                                    if(get_field( 'room-numbers' ) == 3){
                                        $f_room_number3 = true;
                                    }
                                    if(get_field( 'room-numbers' ) == 4){
                                        $f_room_number4 = true;
                                    }
                                    if(get_field( 'room-numbers' ) == 5){
                                        $f_room_number5 = true;
                                    }
                                    //another
                                    if (get_field('terrassa')[0] === 'terrassa'){
                                        $f_terrassa = true;
                                    }
                                    if (get_field('kotelnaya')[0] === 'kotelnaya'){
                                        $f_kotelnaya = true;
                                    }
                                    if (get_field('mansarda')[0] === 'mansarda'){
                                        $f_mansarda = true;
                                    }
                                    if (get_field('secondlight')[0] === 'secondlight'){
                                        $f_secondlight = true;
                                    }
                                }
                            }
                            ?>
                            <div class="filter-name">Тип строения</div>
                            <?php

                            /**
                             * Левое меню с фильтрацией
                             * 🗃
                             */

                            ?>
                            <div class="filter-values flex-column">
                                <?php if($_GET['type-build'] === 'home' || $_GET['type-build'] == ''){ ?>
                                    <label><input class="filter-c" type="checkbox" name="type_build" data-e="home" value="home" <?php if($_GET['type-build'] === 'home'){echo  "checked=\"checked\"";} ?> data-sd-name"type-build" data-sd-value="checked">Дома</label>
                                <?php } ?>
                                <?php if($_GET['type-build'] === 'arbor' || $_GET['type-build'] == ''){ ?>
                                    <label><input class="filter-c" type="checkbox" name="type_build" data-e="arbor" value="arbor" <?php if($_GET['type-build'] === 'home'){echo  "checked=\"checked\"";} ?> data-sd-name"type-build" data-sd-value="arbor">Беседки</label>
                                <?php } ?>
                                <?php if($_GET['type-build'] === 'bathhouse' || $_GET['type-build'] == ''){ ?>
                                    <label><input class="filter-c" type="checkbox" name="type_build" data-e="bathhouse" value="bathhouse" <?php if($_GET['type-build'] === 'bathhouse'){echo  "checked=\"checked\"";} ?> data-sd-name"type-build" data-sd-value="bathhouse">Бани</label>
                                <?php } ?>
                            </div>
                        </div>
                        <div class="filter-item">
                            <div class="filter-name">Цена</div>
                            <div class="filter-values flex-column">
<!--                                price_ot=500000&price_do=1000000-->
<!--                                $price1, $price2-->
                                <?php if($f_price1){ ?>
                                    <label><input class="filter-c" type="checkbox" name="price" data-e="price1" data-min="0" data-max="500000" <?php if($_GET['price_ot'] === '0' && $_GET['price_do'] === '500000' ){echo  "checked=\"checked\"";} ?> data-sd-name"price" data-sd-ot"0" data-sd-do"500000">до 500 тыс. руб.</label>
                                <?php } ?>
                                <?php if($f_price2){ ?>
                                    <label><input class="filter-c" type="checkbox" name="price" data-e="price2" data-min="500000" data-max="1000000" <?php if($_GET['price_ot'] === '500000' && $_GET['price_do'] === '1000000' ){echo  "checked=\"checked\"";} ?> data-sd-name"price" data-sd-ot"500000" data-sd-do"1000000">от 500 тыс. руб. - до 1 млн. руб.</label>
                                <?php } ?>
                                <?php if($f_price3){ ?>
                                    <label><input class="filter-c" type="checkbox" name="price" data-e="price3" data-min="1000000" data-max="1750000" <?php if($_GET['price_ot'] === '1000000' && $_GET['price_do'] === '1750000' ){echo  "checked=\"checked\"";} ?> data-sd-name"price" data-sd-ot"1000000" data-sd-do"1750000">от 1 млн. руб. - до 1,750 млн. руб.</label>
                                <?php } ?>
                                <?php if($f_price4){ ?>
                                    <label><input class="filter-c" type="checkbox" name="price" data-e="price4" data-min="1750000" data-max="2500000" <?php if($_GET['price_ot'] === '1750000' && $_GET['price_do'] === '2500000' ){echo  "checked=\"checked\"";} ?> data-sd-name"price" data-sd-ot"1750000" data-sd-do"2500000">от 1,750 млн. руб. - до 2,5 млн. руб.</label>
                                <?php } ?>
                                <?php if($f_price5){ ?>
                                    <label><input class="filter-c" type="checkbox" name="price" data-e="price5" data-min="2500000" data-max="99999999" <?php if($_GET['price_ot'] === '2500000' && $_GET['price_do'] === '99999999' ){echo  "checked=\"checked\"";} ?> data-sd-name"price" data-sd-ot"2500000" data-sd-do"99999999">от 2,5 млн. руб.</label>
                                <?php } ?>
                            </div>
                        </div>
                        <div class="filter-item">
                            <div class="filter-name">Общая площадь</div>
                            <div class="filter-values flex-column">
<!--                                ?size_ot=0&size_do=50-->
                                <?php if($f_size1){ ?>
                                    <label><input class="filter-c" type="checkbox" name="size" data-e="size1" data-min="0" data-max="50" <?php if($_GET['size_ot'] === '0' && $_GET['size_do'] === '50' ){echo  "checked=\"checked\"";} ?> data-sd-name"size" data-sd-ot"0" data-sd-do"50">до 50 м2</label>
                                <?php } ?>
                                <?php if($f_size2){ ?>
                                    <label><input class="filter-c" type="checkbox" name="size" data-e="size2" data-min="50" data-max="75" <?php if($_GET['size_ot'] === '50' && $_GET['size_do'] === '75' ){echo  "checked=\"checked\"";} ?> data-sd-name"size" data-sd-ot"50" data-sd-do"75">от 50 до 75 м2</label>
                                <?php } ?>
                                <?php if($f_size3){ ?>
                                    <label><input class="filter-c" type="checkbox" name="size" data-e="size3" data-min="75" data-max="120" <?php if($_GET['size_ot'] === '75' && $_GET['size_do'] === '120' ){echo  "checked=\"checked\"";} ?> data-sd-name"size" data-sd-ot"75" data-sd-do"120">от 75 до 120 м2</label>
                                <?php } ?>
                                <?php if($f_size4){ ?>
                                    <label><input class="filter-c" type="checkbox" name="size" data-e="size4" data-min="120" data-max="200" <?php if($_GET['size_ot'] === '120' && $_GET['size_do'] === '200' ){echo  "checked=\"checked\"";} ?> data-sd-name"size" data-sd-ot"120" data-sd-do"200">от 120 до 200 м2</label>
                                <?php } ?>
                                <?php if($f_size5){ ?>
                                    <label><input class="filter-c" type="checkbox" name="size" data-e="size5" data-min="200" data-max="300" <?php if($_GET['size_ot'] === '200' && $_GET['size_do'] === '300' ){echo  "checked=\"checked\"";} ?> data-sd-name"size" data-sd-ot"200" data-sd-do"300">от 200 до 300 м2</label>
                                <?php } ?>
                                <?php if($f_size6){ ?>
                                    <label><input class="filter-c" type="checkbox" name="size" data-e="size6" data-min="300" data-max="400" <?php if($_GET['size_ot'] === '300' && $_GET['size_do'] === '400' ){echo  "checked=\"checked\"";} ?> data-sd-name"size" data-sd-ot"300" data-sd-do"400">от 300 до 400 м2</label>
                                <?php } ?>
                            </div>
                        </div>
                        <div class="filter-item">
                            <div class="filter-name">Количество этажей</div>
                            <div class="filter-values flex-column">
<!--                                //&floors-numbers=1-->
                                <?php if($f_floors_number1){ ?>
                                    <label><input class="filter-c" type="checkbox" data-e="floors_numbers1" name="floors_numbers" value="1" <?php if($_GET['floors-numbers'] === '1'){echo  "checked=\"checked\"";} ?> data-sd-name"floors-numbers" data-sd-value="1">1</label>
                                <?php } ?>
                                <?php if($f_floors_number2){ ?>
                                    <label><input class="filter-c" type="checkbox" data-e="floors_numbers2" name="floors_numbers" value="2" <?php if($_GET['floors-numbers'] === '2'){echo  "checked=\"checked\"";} ?> data-sd-name"floors-numbers" data-sd-value="2">2</label>
                                <?php } ?>
                            </div>
                        </div>
                        <div class="filter-item">
                            <div class="filter-name">Количество комнат</div>
                            <div class="filter-values flex-column">
                                <?php if($f_room_number1){ ?>
                                    <label><input class="filter-c" type="checkbox" data-e="room_numbers1" name="room_numbers" value="1" <?php if($_GET['room-numbers'] === '1'){echo  "checked=\"checked\"";} ?> data-sd-name"room-numbers" data-sd-value="1">1</label>
                                <?php } ?>
                                <?php if($f_room_number2){ ?>
                                    <label><input class="filter-c" type="checkbox" data-e="room_numbers2" name="room_numbers" value="2" <?php if($_GET['room-numbers'] === '2'){echo  "checked=\"checked\"";} ?> data-sd-name"room-numbers" data-sd-value="2">2</label>
                                <?php } ?>
                                <?php if($f_room_number3){ ?>
                                    <label><input class="filter-c" type="checkbox" data-e="room_numbers3" name="room_numbers" value="3" <?php if($_GET['room-numbers'] === '3'){echo  "checked=\"checked\"";} ?> data-sd-name"room-numbers" data-sd-value="3">3</label>
                                <?php } ?>
                                <?php if($f_room_number4){ ?>
                                    <label><input class="filter-c" type="checkbox" data-e="room_numbers4" name="room_numbers" value="4" <?php if($_GET['room-numbers'] === '4'){echo  "checked=\"checked\"";} ?> data-sd-name"room-numbers" data-sd-value="4">4</label>
                                <?php } ?>
                                <?php if($f_room_number5){ ?>
                                    <label><input class="filter-c" type="checkbox" data-e="room_numbers5" name="room_numbers" value="5" <?php if($_GET['room-numbers'] === '5'){echo  "checked=\"checked\"";} ?> data-sd-name"room-numbers" data-sd-value="5">5</label>
                                <?php } ?>
                            </div>
                        </div>
                        <div class="filter-item">
                            <div class="filter-name">Дополнительно</div>
                            <div class="filter-values flex-column">
                                <?php if($f_terrassa){ ?>
                                    <label><input class="filter-c" type="checkbox" data-e="another1" name="another" value="terrassa" <?php if($_GET['terrassa'] === 'terrassa'){echo  "checked=\"checked\"";} ?> data-sd-name"terrassa" data-sd-value="terrassa">С террасой</label>
                                <?php } ?>
                                <?php if($f_kotelnaya){ ?>
                                    <label><input class="filter-c" type="checkbox" data-e="another2" name="another" value="kotelnaya" <?php if($_GET['kotelnaya'] === 'kotelnaya'){echo  "checked=\"checked\"";} ?> data-sd-name"kotelnaya" data-sd-value="kotelnaya">С котельной</label>
                                <?php } ?>
                                <?php 	if($f_mansarda){ ?>
                                    <label><input class="filter-c" type="checkbox" data-e="another3" name="another" value="mansarda" <?php if($_GET['mansarda'] === 'mansarda'){echo  "checked=\"checked\"";} ?> data-sd-name"mansarda" data-sd-value="mansarda">С мансандрой</label>
                                <?php } ?>
                                <?php 	if($f_secondlight){ ?>
                                    <label><input class="filter-c" type="checkbox" data-e="another4" name="another" value="secondlight" <?php if($_GET['secondlight'] === 'secondlight'){echo  "checked=\"checked\"";} ?> data-sd-name"secondlight" data-sd-value="secondlight">Со вторым светом</label>
                                <?php } ?>
                            </div>
                        </div>

                    </div>


                    <div class="col-xs-12 col-md-9 products-c">
                        <?php

                        $query = new WP_Query( $args );
                        $paged = (get_query_var('page')) ? get_query_var('page') : 1;?>
                        <script type='text/javascript'>
                            var maxppages = <?php echo ceil($query->found_posts / $query->post_count) ?>;
                        </script>
                        <div class="row row-product">
                            <?php	$count_pages = ceil($query->found_posts / $query->post_count);
                            if ( $query->have_posts() ) {
                                while ( $query->have_posts() ) {
                                    $query->the_post();?>
                                    <div class="col-xs-12 col-md-4">
                                        <a href="<?php the_permalink() ?>" class="order-link" data-id="<?php echo get_the_ID(); ?>">
                                            <div class="order-item">
                                                <div class="img-box">
                                                    <?php if(has_post_thumbnail()) : ?>
                                                        <?php the_post_thumbnail('project-main',array( 'alt' => get_the_title() )); ?>
                                                    <?php else : ?>
                                                        <img src="<?php echo get_template_directory_uri() ?>/img/placeholder.jpg" alt="placeholder">
                                                    <?php endif; ?>
                                                    <?php if(get_field('totop')) : ?>
                                                        <div class="top">
                                                            <?php the_field('totop') ?>
                                                        </div>
                                                    <?php endif; ?>
                                                    <div class="favorite-c"><img src="<?php echo get_template_directory_uri()?>/img/favorite.svg" alt=""></div>
                                                    <div class="title">
                                                        <?php the_title() ?>
                                                    </div>
                                                </div>
                                                <div class="info-box">
                                                    <figure>
                                                        <div class="order-tr">
                                                            <span>жил. пл.</span>
                                                            <p>
                                                                <?php echo get_field( 'live-area' ); ?> м<sup>2</sup></p>
                                                        </div>
                                                        <div class="order-tr">
                                                            <span>общ. пл.</span>
                                                            <p>
                                                                <?php echo get_field( 'size' ); ?> м<sup>2</sup></p>
                                                        </div>
                                                        <div class="order-tr">
                                                            <span>кол.комнат</span>
                                                            <p>
                                                                <?php echo get_field( 'room-numbers' ); ?>
                                                            </p>
                                                        </div>
                                                    </figure>
                                                    <div class="price">
                                                        Цена сегодня
                                                        <span><span class="summa">
													<?php echo get_field( 'price' ); ?></span><i> ₽</i></span>
                                                    </div>
                                                </div>
                                            </div>
                                        </a>
                                    </div>
                                <?php }
                            }

                            wp_reset_postdata();
                            ?>

                        </div>

                    </div>

                </div>
                <div class="row">
                    <div class="col-lg-push-3 col-lg-9 flex-c jcc">
                        <div class="pagination-block-c flex-c">
                            <nav aria-label=...>
                                <ul class="pagination">
                                    <!-- <li id="previous-page"><a href="javascript:void(0)" aria-label=Previous><span aria-hidden=true>&laquo;</span></a></li> -->
                                </ul>
                            </nav>
                            <!-- <button type="button" class="pagination-item-btn pagination-item-prev"><i class="arrow-c left-c"></i></button> -->

                            <!-- <input type="button" class="pagination-item pagination-item-active" value="1">
                            <input type="button" class="pagination-item" value="2">
                            <input type="button" class="pagination-item" value="3"> -->

                            <!-- <button type="button" class="pagination-item-btn pagination-item-next"><i class="arrow-c right-c"></i></button> -->
                        </div>
                    </div>
                </div>
                <div class="dont-find-proj-section">

                    <div class="row">
                        <div class="col-sm-4">
                            <div class="title">Не нашли нужного проекта?</div>
                            <div class="subtitle">Присылайте свой чертеж для бесплатного проектирования и рассчета сметы</div>
                            <a href="#send-drawing-popup" class="btn-accent middle popup-with-move-anim">Прислать чертеж</a>
                        </div>
                        <div class="col-sm-8">
                            <div class="img-box">
                                <img src="<?php echo get_template_directory_uri() ?>/img/dont-find-project-bg.jpg" alt="">
                            </div>
                        </div>
                    </div>

                </div>

                <div class="triggers-section">

                    <div class="row">
                        <div class="col-xs-12 col-sm-12">
                            <div class="section-title-box">
                                <h3 class="section-title">Дополнительные выгоды</h3>
                            </div>
                        </div>
                    </div>
                    <div class="triggers">
                        <div class="row">
                            <div class="col-xs-12 col-sm-4 col-md-2">
                                <div class="trigger wow fadeInDown">
                                    <div class="img-box"><i class="icon-shield"></i></div>
                                    <div class="description">Гарантия до 10 лет</div>
                                </div>
                            </div>
                            <div class="col-xs-12 col-sm-4 col-md-2">
                                <div class="trigger wow fadeInDown" data-wow-delay="0.1s">
                                    <div class="img-box"><i class="icon-list-ok"></i></div>
                                    <div class="description">Работаем строго по утвержденной смете</div>
                                </div>
                            </div>
                            <div class="col-xs-12 col-sm-4 col-md-2">
                                <div class="trigger wow fadeInDown" data-wow-delay="0.2s">
                                    <div class="img-box"><i class="icon-worker"></i></div>
                                    <div class="description">Бесплатный вызов специалиста на участок</div>
                                </div>
                            </div>
                            <div class="col-xs-12 col-sm-4 col-md-2">
                                <div class="trigger wow fadeInDown" data-wow-delay="0.3s">
                                    <div class="img-box"><i class="icon-hand-r"></i></div>
                                    <div class="description">Поэтапная оплата</div>
                                </div>
                            </div>
                            <div class="col-xs-12 col-sm-4 col-md-2">
                                <div class="trigger wow fadeInDown" data-wow-delay="0.4s">
                                    <div class="img-box"><i class="icon-telega"></i></div>
                                    <div class="description">Возможность строительства в кредит</div>
                                </div>
                            </div>
                            <div class="col-xs-12 col-sm-4 col-md-2">
                                <div class="trigger wow fadeInDown" data-wow-delay="0.5s">
                                    <div class="img-box"><i class="icon-magnifier"></i></div>
                                    <div class="description">Контроль качества на каждом этапе</div>
                                </div>
                            </div>
                        </div>
                    </div>


                </div>

                <div class="catalog-text">
                    <?php the_content(); ?>
                </div>
            </div>
        </main>
    </div>
<?php
get_sidebar();
get_footer();