Hi,
doesn’t work.
in function.php:
add_action(‘pre_get_posts’, ‘my_pre_get_posts’);
function my_pre_get_posts( $query )
{
// validate
if( is_admin() )
{
return;
}
if( !$query->is_main_query() )
{
return;
}
$meta_query = $query->get(‘meta_query’);
if( !empty($_GET[‘auswahl’]) )
{
$bedrooms = explode(‘,’, $_GET[‘auswahl’]);
//Add our meta query to the original meta queries
$meta_query[] = array(
‘key’ => ‘p_reihe’,
‘value’ => $bedrooms,
‘compare’ => ‘IN’,
);
$bathrooms = explode(‘,’, $_GET[‘bathrooms’]);
$meta_query[] = array(
‘key’ => ‘p_energieklasse’,
‘value’ => $bathrooms,
‘compare’ => ‘IN’,
);
}
// update the meta query args
$query->set(‘meta_query’, $meta_query);
// always return
return;
}
in archive.php:
<div id=”search-houses”>
<?php
$field = get_field_object(‘p_reihe’);
$values = isset($_GET[‘p_reihe’]) ? explode(‘,’, $_GET[‘p_reihe’]) : array();
?>
<?php endforeach; ?>
<?php
$field = get_field_object(‘p_energieklasse’);
$values = isset($_GET[‘p_energieklasse’]) ? explode(‘,’, $_GET[‘p_energieklasse’]) : array();
?>
<?php foreach( $field[‘choices’] as $choice_value => $choice_label ): ?>
<?php endforeach; ?>
</div>
<script type=”text/javascript”>
(function($) {
$(‘#search-houses’).on(‘change’, ‘input[type=”checkbox”]’, function(){
// vars
var $ul = $(this).closest(‘ul’),
vals = [];
$ul.find(‘input:checked’).each(function(){
vals.push( $(this).val() );
});
vals = vals.join(“,”);
window.location.replace(‘http://www.jemaniblue.ch/kategorie/handbrausen/?auswahl=’ + vals);
console.log( vals );
});
})(jQuery);
</script>
Hi,
works fine. thx.
If like to style the map e.g.:
function render_map( $el ) {
// var
var $markers = $el.find(‘.marker’);
// vars
var args = {
zoom : 4,
center : new google.maps.LatLng(0, 0),
mapTypeId : google.maps.MapTypeId.ROADMAP,
styles: [{“stylers”:[{“lightness”:5},{“gamma”:1.2},{“saturation”:-80},{“visibility”:”on”},{“weight”:0.1},{“hue”:”#ddd”}]}]};
Hi,
thx. doesn`t work. shows an empty map.
regards
andreas
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!
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.