@style_kras

Не правильно работает фильтр записей, нужно чтоб фильтровал в алфавитном порядке, да?

подскажите что с кодом не так? нужно чтоб поиск фильтровал в алфавитном порядке, сейчас не понятно как он находит, вот код фильтра:
<?php
$ecr_2_title      = get_field( 'ecr_2_title', 'options' );
$ecr_2_text   = get_field( 'ecr_2_text', 'options' );
?>
<div class="form-filter">
	<div class="form-filter__heading">
		<?php if ( $ecr_2_title ) { ?>
            <div class="middle-title form-filter__title"><?php echo $ecr_2_title; ?></div>
		<?php } ?>
		<?php if ( $ecr_2_text ) { ?>
            <div class="form-filter__desc"><?php echo $ecr_2_text; ?></div>
		<?php } ?>
	</div>
	<form action="<?php bloginfo( 'url' ); ?>" class="form-filter__list ajax-filter">
        <input type="hidden" name="s" value="">
		<div class="form-filter__list-item">
			<?php
			if(!empty($_GET['type'])){
				$current_slug = $_GET['type'];
				$term = get_term_by('slug', $current_slug, 'type');
				$current_name = $term->name;
			} else {
				$current_name = 'Все';
				$current_slug = '';
			}
			$filterCat = $current_name;
			?>
			<div class="item-select">
				<div class="item-select__label">Выберите тип курса:</div>
				<div class="item-select__body">
					<div class="item-select__current"><?php echo $current_name; ?></div>
					<div class="item-select__list">
						<div class="item-select__option" data-value="">Все</div>
						<?php
						$args  = array(
							'taxonomy'   => 'type',
							'orderby' => 'name',
							'order' => 'ASC',
							'hide_empty' => false,
						);

						$categories = get_terms( $args );
						foreach ( $categories as $cat ) {
						?>
						<div class="item-select__option" data-value="<?php echo $cat->slug; ?>"><?php echo $cat->name; ?></div>
						<?php } ?>
					</div>
				</div>
				<input type="hidden" value="<?php echo $current_slug; ?>" name="type" class="item-select__hidden">
			</div>
		</div>
		<div class="form-filter__list-item">
			<?php
			if(!empty($_GET['specialist'])){
				$current_slug = $_GET['specialist'];
				$term = get_term_by('slug', $current_slug, 'specialist');
				$current_name = $term->name;
			} else {
				$current_name = 'Все';
				$current_slug = '';
			}
			?>
			<div class="item-select">
				<div class="item-select__label">Специальность:</div>
				<div class="item-select__body" id="filter_select_job">
					<input type="text" value="" size="40" placeholder="" class="job_choose_filter" hidden>
					<div class="item-select__current"><?php echo $current_name; ?></div>
					<div class="item-select__list">
						<div class="item-select__option" data-value="">Все</div>
						<?php
						$args  = array(
							'taxonomy'   => 'specialist',
							'orderby' => 'name',
							'order' => 'ASC',
							'hide_empty' => false,
						);

						$categories = get_terms( $args );
						foreach ( $categories as $cat ) {
							?>
                            <div class="item-select__option" data-value="<?php echo $cat->slug; ?>"><?php echo $cat->name; ?></div>
						<?php } ?>
					</div>
				</div>
				<input type="hidden" value="<?php echo $current_slug; ?>" name="specialist" class="item-select__hidden">
			</div>
		</div>
		<div class="form-filter__list-item">
			<div class="item-select">
                <?php
                    if(!empty($_GET['time'])){
                        $current_slug = $_GET['time'];
	                    $term = get_term_by('slug', $current_slug, 'time');
	                    $current_name = $term->name;
                    } else {
	                    $current_name = 'Выбрать';
	                    $current_slug = '';
                    }
                ?>
				<div class="item-select__label">Часовая нагрузка:</div>
				<div class="item-select__body">
					<div class="item-select__current"><?php echo $current_name; ?></div>
					<div class="item-select__list">
						<div class="item-select__option" data-value="">Выбрать</div>
						<?php
						$args  = array(
							'taxonomy'   => 'time',
                            'orderby' => 'name',
							'order' => 'ASC',
							'hide_empty' => false,
						);

						$categories = get_terms( $args );
						foreach ( $categories as $cat ) {
							?>
                            <div class="item-select__option" data-value="<?php echo $cat->slug; ?>"><?php echo $cat->name; ?></div>
						<?php } ?>
					</div>
				</div>
				<input type="hidden" name="time" value="<?php echo $current_slug; ?>" class="item-select__hidden">
			</div>
		</div>
		<div class="form-filter__list-item-btn">
			<button class="btn-site form-filter__btn ajax-filter--btn">
				<img src="<?php echo get_template_directory_uri(); ?>/build/img/search-btn.png" width="32" height="32" alt="">
			</button>
		</div>
	</form>
	<?php if( is_front_page() ) { ?>
    <div class="small-title form-filter__small-title">Поиск курса по названию</div>
    <form method="GET" action="<?php bloginfo( 'url' ); ?>" class="search-style">
        <input type="text" name="s" class="search-style__item" placeholder="Введите название курса, или специальность">
        <button class="search-style__btn" type="submit">Найти</button>
    </form>
	<?php } ?>
</div>
  • Вопрос задан
  • 27 просмотров
Пригласить эксперта
Ваш ответ на вопрос

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

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