Home › Forums › Front-end Issues › Advanced search form
Hi,
I have a template which has an search screen at the homepage.
At this moment it uses the normal field to search but i want it to use the fields that i created with ACF. I do not know what i should change.
Could someone please help me with this?
Here is my advanced.search.php
<?php
/**
* Advanced Search Template
*
* @package WP Pro Real Estate 5
* @subpackage Template
*/
global $ct_options;
$layout = $ct_options[‘ct_homepage_adv_search’][‘enabled’];
?>
<h3 class=”marT0 marB0″><?php _e(‘Find your new home’, ‘contempo’); ?></h3>
<p class=”marB0″><?php $count_posts = wp_count_posts(‘listings’); $published_listings = $count_posts->publish; ?><?php echo $published_listings ?> <?php _e(‘Real Estate Listings, Homes for Sale & Rental Properties.’, ‘contempo’); ?></p>
<form id=”advanced_search” name=”search-listings” action=”<?php echo home_url(); ?>”>
<?php
if ($layout) :
foreach ($layout as $key=>$value) {
switch($key) {
// Type
case ‘type’ : ?>
<div class=”left”>
<label for=”ct_type”><?php _e(‘Type’, ‘contempo’); ?></label>
<?php ct_search_form_select(‘property_type’); ?>
</div>
<?php
break;
// City
case ‘city’ : ?>
<div class=”left”>
<label for=”ct_city”><?php _e(‘City’, ‘contempo’); ?></label>
<?php ct_search_form_select(‘city’); ?>
</div>
<?php
break;
// State
case ‘state’ : ?>
<div class=”left”>
<label for=”ct_state”><?php _e(‘State’, ‘contempo’); ?></label>
<?php ct_search_form_select(‘state’); ?>
</div>
<?php
break;
// Zipcode
case ‘zipcode’ : ?>
<div class=”left”>
<label for=”ct_zipcode”><?php _e(‘Zipcode’, ‘contempo’); ?></label>
<?php ct_search_form_select(‘zipcode’); ?>
</div>
<?php
break;
// Beds
case ‘beds’ : ?>
<div class=”left”>
<label for=”slaapkamers”><?php _e(‘Slaapkamers’, ‘contempo’); ?></label>
<?php ct_search_form_select(‘beds’); ?>
</div>
<?php
break;
// Baths
case ‘baths’ : ?>
<div class=”left”>
<label for=”ct_baths”><?php _e(‘Baths’, ‘contempo’); ?></label>
<?php ct_search_form_select(‘baths’); ?>
</div>
<?php
break;
// Status
case ‘status’ : ?>
<div class=”left”>
<label for=”ct_status”><?php _e(‘Status’, ‘contempo’); ?></label>
<?php ct_search_form_select(‘ct_status’); ?>
</div>
<?php
break;
// Additional Features
case ‘additional_features’ : ?>
<div class=”left”>
<label for=”ct_additional_features”><?php _e(‘Addtional Features’, ‘contempo’); ?></label>
<?php ct_search_form_select(‘additional_features’); ?>
</div>
<?php
break;
// Price From
case ‘price_from’ : ?>
<div class=”left”>
<label for=”ct_price_from”><?php _e(‘Price From’, ‘contempo’); ?> (<?php currency(); ?>)</label>
<input type=”text” id=”ct_price_from” class=”number” name=”ct_price_from” size=”8″ />
</div>
<?php
break;
// Price To
case ‘price_to’ : ?>
<div class=”left”>
<label for=”ct_price_to”><?php _e(‘Price To’, ‘contempo’); ?> (<?php currency(); ?>)</label>
<input type=”text” id=”ct_price_to” class=”number” name=”ct_price_to” size=”8″ />
</div>
<?php
break;
// MLS
case ‘mls’ : ?>
<div class=”left”>
<label for=”ct_mls”><?php _e(‘MLS #’, ‘contempo’); ?></label>
<input type=”text” id=”ct_mls” name=”ct_mls” size=”12″ />
</div>
<?php
break;
}
} endif; ?>
<input type=”hidden” name=”search-listings” value=”true” />
<input id=”submit” class=”btn left” type=”submit” value=”<?php _e(‘Search’, ‘contempo’); ?>” />
<div class=”clear”></div>
</form>
Old question, you’ve probably moved on. I’m just trying to clear up some older questions.
Anyway, I’m not going to go into all the details, but hopefully get other people looking to solve a similar question headed in the right direction.
In a case like this the first thing you need to do is edit the advanced search form to add the new fields that you want to use. Then next step would be finding where the query is run using these fields and alter that query to include you new fields and values. There really isn’t enough information available in the OP to go into more detail than this.
Hope that helps someone.
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!
Are you building WordPress sites with ACF and @BeaverBuilder, and wanted to use your ACF Blocks in both the block editor and Beaver Builder?
— Advanced Custom Fields (@wp_acf) May 10, 2023
The BB team recently added support for using ACF Blocks in Beaver Builder. Check it out 👇https://t.co/UalEIa5aQi
© 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.