• Всем добрый день, вот мучаюсь над фильтром для записей, фильтр по категориям получилось сделать кое как, только вот по custom field никак, может кто подскажет

     * The template for displaying all pages.
     * This is the template that displays all pages by default.
     * Please note that this is the WordPress construct of pages
     * and that other 'pages' on your WordPress site will use a
     * different template.
     global $wp_query;
    $modifications = array();
    if( !empty( $_GET['cat'] ) ) {
    	$modifications['meta_query'][] = array(
    		'key' => 'cat',
    		'value' => $_GET['cat'],
    		'compare' => '!='
    get_header(); ?>
    	<div id="primary-mono" class="content-area <?php do_action('tribal_primary-width') ?> page">
    		<main id="main" class="site-main" role="main">
    			<form action="<?php echo get_permalink(251); ?>" method="get" class="post-filters">
    				<select id="selectBox" name="work_type">
    					<option value=''><?php _e('work type', 'tribal') ?></option>
    					<option value='10' <?php if($_GET['work_type'] == '10'){echo 'selected';} ?>><?php _e('Construction', 'tribal') ?></option>
    					<option value='11' <?php if($_GET['work_type'] == '11'){echo 'selected';} ?>><?php _e('Design', 'tribal') ?></option>
    					<option value='13' <?php if($_GET['work_type'] == '13'){echo 'selected';} ?>><?php _e('Designing', 'tribal') ?></option>
    					<option value='9' <?php if($_GET['work_type'] == '9'){echo 'selected';} ?>><?php _e('Portfolio', 'tribal') ?></option>
    				<select id="select_status" name="status_type">
    					<option value=''><?php _e('status', 'tribal') ?></option>
    					<option value='build' <?php if($_GET['status_type'] == 'build'){echo 'selected';} ?>><?php _e('build', 'tribal') ?></option>
    					<option value='construction_completed' <?php if($_GET['status_type'] == 'construction_completed'){echo 'selected';} ?>><?php _e('construction completed', 'tribal') ?></option>
    				<select id="select_location" name="location_type">
    					<option value=''><?php _e('location', 'tribal') ?></option>
    					<option value=''></option>
    					<option value=''></option>
    					<option value=''></option>
    				<select id="select_date" name="date_type">
    					<option value=''><?php _e('date', 'tribal') ?></option>
    					<option value=''></option>
    					<option value=''></option>
    					<option value=''></option>
    				<input type="submit" class="" />
    					<div class="buttons"><button class="grid"><p class="icon1"></p><?php _e('Grid', 'tribal') ?></button>
    			<button class="list"><p class="icon2"></p><?php _e('List', 'tribal') ?></button>
    		<div id="container">
    		 <div class="portfolio-list">
    							$cats = '10,11,13,9';
    							$cats = $_GET['work_type'];
                            $paged = ( get_query_var( 'paged' ) ) ? get_query_var( 'paged' ) : 1;
                            $temp = $wp_query;
                            $wp_query= null;
                            $args = array(
                                'paged' => $paged,
                                'post_type' => 'post',
                                'posts_per_page' => '18',
    							'cat' => $cats,
                                'orderby' => 'date',
                                'order' => 'DESC',
                            $wp_query = new WP_Query($args);
                            while($wp_query->have_posts()) :
    						<div class="item">
                                <a href="<?php the_permalink(); ?>"><?php the_post_thumbnail(); ?><p><?php the_title(); ?></p></a>
                        <?php endwhile; ?>
                        <?php endif; ?>
                    echo '<div class="pagination">';
                    		if(function_exists('wp_pagenavi')) { wp_pagenavi(array('query' => $wp_query)); }
                    		$wp_query = null; $wp_query = $temp;
                    echo '</div>';
                    <div class="clearfix"></div>
    		</main><!-- #main -->
    	</div><!-- #primary -->
    <?php get_sidebar(); ?>
    <?php get_footer(); ?>
  • Тема «фильтр записей по категориям и кастомным полям» закрыта для новых ответов.