Forums › Forums › Search & Filter Pro › How to implement?
- This topic has 22 replies, 2 voices, and was last updated 7 years, 10 months ago by Trevor.
-
Anonymous(Private) December 20, 2016 at 6:02 am #77686
Hi,
I am trying to make a filter like this: http://i.imgur.com/3IU1LEU.png (they’re all just radio buttons and a range slider).
I have a page called “packages”. On that page I am listing all posts from the house_and_land custom post type. But honestly I’m not sure where to proceed form here.
I don’t need to use the search field, but instead when a user arrives at the “packages” page they will immediately see all the posts listed and the search filter next to it.
This is my code for listing all the house_and_land posts:
$args = array( 'posts_per_page' => 5, 'post_type' => 'house_and_land' ); $properties_query = new WP_Query( $args ); if( $properties_query->have_posts() ): while( $properties_query->have_posts() ) : $properties_query->the_post(); // Vars $estate = get_field( 'estate' ); $home_area = get_field( 'home_area' ); $min_lot_width = get_field( 'min_lot_width' ); $storeys = get_field( 'storeys' ); $bed = get_field( 'bed' ); $bath = get_field( 'bath' ); $car = get_field( 'car' ); $price = get_field( 'price' ); ?> <li> <a href="<?php echo the_permalink(); ?>"> <span class="estate"><?php echo get_the_title( $estate ); ?></span> <span class="line-item estate min">Min lot width: <em><?php echo $min_lot_width; ?>m</em></span> <span class="line-item estate area">Home area: <em><?php echo $home_area; ?>m<sup>2</sup></em></span> <span class="line-item estate storeys">Storeys: <em><?php echo $storeys; ?></em></span> <span class="line-item estate bed">Bed: <em><?php echo $bed; ?></em></span> <span class="line-item estate bath">Bath: <em><?php echo $bath; ?></em></span> <span class="line-item estate car">Car: <em><?php echo $car; ?></em></span> <span class="price">From <em>$<?php echo $price; ?></em></span> </a> </li> <?php endwhile; endif; wp_reset_query();
How do I get the search filters to work? As shown in the image (http://i.imgur.com/3IU1LEU.png) I need radio buttons for beds, baths, garages, storeys, and range sliders for price range and lot width. But the WP backend interface for S&F doesn’t make it obvious how to do that.
Thanks in advance.
Anonymous(Private) December 20, 2016 at 6:45 am #77688Update: Oh my apologies – I didn’t realise it has Advanced Custom Fields support. That’s pretty awesome actually.
So now I’ve got my fields showing on the page like this: http://i.imgur.com/unyW7aG.png
Problem is when I put this on the page template…
echo do_shortcode( '[searchandfilter id="405"]' );
…I still see all my posts regardless of what filter selections I make.
Does my shortcode need to be in a particular place? Or is it broken in some other way?
Please advise.
Thanks.
Trevor(Private) December 23, 2016 at 10:27 am #78447Hi. I took a quick look at your setup. You have correctly chosen to use the Shortcode method. However, this method uses our own template (which you can modify, see here for the documentation). And then, on the page, you should have the shortcode to output those results using that template. The Custom method can allow you to use your own template, but I tried that for you and it did not go well.
-
AuthorPosts