Support

Account

Forum Replies Created

  • 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 foreach( $field[‘choices’] as $choice_value => $choice_label ): ?>

    • <input type=”checkbox” value=”<?php echo $choice_value; ?>” <?php if( in_array($choice_value, $values) ): ?>checked=”checked”<?php endif; ?> /> <?php echo $choice_label; ?>
    • <?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 ): ?>

    • <input type=”checkbox” value=”<?php echo $choice_value; ?>” <?php if( in_array($choice_value, $values) ): ?>checked=”checked”<?php endif; ?> /> <?php echo $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=&#8217; + 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

Viewing 4 posts - 1 through 4 (of 4 total)