Home › Forums › Front-end Issues › 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(); ?>
You must be logged in to reply to this topic.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
CPT registration is coming to ACF! We demoed the new feature during the most recent session of ACF Chat Fridays. Check out the summary for the details. https://t.co/k2KQ3WWBAz
— Advanced Custom Fields (@wp_acf) March 7, 2023
© 2023 Advanced Custom Fields.
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Cookie Policy. If you continue to use this site, you consent to our use of cookies.