Support

Account

Home Forums Front-end Issues Comparing numeric values is not working Help

Unread

Comparing numeric values is not working Help

  • i m making just a small filter a simple real estate filter ( nature, type, location, price_range) all fields worked and just price range is not working properly knowing that i flowed your official Guide demo of my website LINK

    get_header(); ?>
    
    	<section id="primary" class="content-area">
    		<main id="main" class="site-main" role="main">
            <?php //print_r($_GET); ?>
    		<?php if ( have_posts() ) : ?>
    
    			<header class="page-header">
    				<h1 class="page-title"><?php printf( __( 'Search Results for: %s', 'alizee' ), '<span>' . get_search_query() . '</span>' ); ?></h1>
    			</header><!-- .page-header -->
    
                 <!--BEGNI-->
    
    			 <?php 
    
    			
                if ($_GET['prix'] == "50000"){
    			   $prix_min = 0;
    			   $prix_max = 50000;
    			}
    			if ($_GET['prix'] == "100000"){
    				$prix_min = 50000;
    				$prix_max = 100000;
    			}
    			if ($_GET['prix'] == "500000"){
    				$prix_min = 500000;
    				$prix_max = 1000000;
    			}
    			if ($_GET['prix'] == "10000000"){
    				$prix_min = 500000;
    				$prix_max = 10000000;
    			}
    			if ($_GET['prix'] == "Tout"){
    				$prix_min = 0;
    				$prix_max = 100000000;
    			}
    			
    			$posts = get_posts(array(
    				'numberposts'	=> -1,
    				'post_type'		=> 'post',
    				'orderby'  => 'meta_value_num', 
    				'order' => 'ASC',
    				'meta_query'	=> array(
    					'relation'		=> 'AND',
    
    					array(
    						'key'	  	=> 'prix',
    						'value' => array($prix_min, $prix_max),
    						'compare' => 'BETWEEN',
    						'type' => 'NUMERIC'
    					),
    					array(
    						'key'	  => 'type',
    						'value'   => $_GET['nature'],
    						'compare' => '=',
    					),
    					array(
    						'key'	  => 'categorie',
    						'value'   => $_GET['categorie'],
    						'compare' => '=',
    					),
    					array(
    						'key'	  => 'adresse',
    						'value'   => $_GET['location'],
    						'compare' => '=',
    					),
    
    				),
    			));
    
    			if( $posts ): ?>
    	
    				<ul>
    					
    				<?php foreach( $posts as $post ): 
    					
    					setup_postdata( $post );
    					
    					?>
    					<li> 
    						<?php get_template_part( 'content', 'search' ); ?>
    					</li>
    				
    				<?php endforeach; ?>
    				
    				</ul>
    	
    			<?php wp_reset_postdata(); ?>
    
    			<?php endif; ?>
    
    			 <!--END--->
    
    			<?php alizee_paging_nav(); ?>
    
    		<?php else : ?>
    
    			<?php get_template_part( 'content', 'none' ); ?>
    
    		<?php endif; ?>
    
    		</main><!-- #main -->
    	</section><!-- #primary -->
    	<?php echo get_search_query(); ?>
    <?php get_sidebar(); ?>
    <?php get_footer(); ?>
    
Viewing 1 post (of 1 total)

The topic ‘Comparing numeric values is not working Help’ is closed to new replies.