-
Search Results
-
Topic: Accessing the Search Data
Hello,
when I try to output currently selected filter values, this is working:echo $sf_current_query->get_field_string(“_sfm_category”);
But this is not working, as well as any filter that start with _sfm:
echo $sf_current_query->get_field_string(“_sfm_character”);What can be reason?
Hi
sorry for english i’m french. I got a little problem with my custom post template page. I got “reference” custom post type, with ajax system who display content ref when clic on ref’s list.
but if i filter results with plugin, my ajax doesn’t work anymore. how can i reload my ajax after display results ?
you can test there : http://syntesia.smartinteractive.net/references/
this is my ajax function :
(function($) { $(document).ready(function() { //$( '.ref_item' ).click( function() { $("#gallery-content-center").on("click", ".ref_item", function() { var post_id = jQuery(this).attr('id'); console.log('cliqué : '+post_id); jQuery.ajax({ url : display_ref.ajax_url, type : 'post', data : { action : 'display_ref', post_id : post_id }, success : function( response ) { //alert(response); $('.fullnews').hide('fast'); $('.fullnews').html( response ).slideDown('fast'); $('.fullnews').show('fast'); var thumbH = $('.fullnews .left').height(); var arrow_top = (thumbH*1.08 - 175)/2; var windowsH = $(window).height(); $('.fullnews .right').css('height',thumbH+'px'); $('.arrow-left, .arrow-right').css('top',arrow_top+'px'); $('.overlay').css('display','block'); $('#overlay'+post_id).css('display','none'); $('html, body').animate( { scrollTop: $('.fullnews').offset().top }, 1000 ); //console.log('thumbH : '+thumbH+' arrow_top : '+arrow_top+' windowsH : '+windowsH); //console.log('réponse: '+response); } }); }); }); })( jQuery );and how i declare them in wordpress :
wp_register_script( 'ajax_ref', get_template_directory_uri().'/js/ajax_ref.js', 'jquery', time(), true ); wp_enqueue_script( 'ajax_ref' ); wp_localize_script( 'ajax_ref', 'display_ref', array( 'ajax_url' => admin_url( 'admin-ajax.php' ) ));and the response :
add_action( 'wp_ajax_nopriv_display_ref', 'display_ref' ); add_action( 'wp_ajax_display_ref', 'display_ref' ); function display_ref() { if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) { $post_id = $_POST['post_id']; global $post; setup_postdata( $post ); $args = array( 'post_type' => 'reference', 'posts_per_page' => -1, 'order'=>'ASC', ); $posts = get_posts($args); foreach ($posts as $post) { if($post_id == $post->ID): echo '<div class="col-md-1">'; echo '</div>'; echo '<div class="col-md-5 left">'; echo '<span class="title">' . get_the_title($post->ID) . '</span>'; echo '<div class="content">' . get_field('description', $post->ID) . '</div>'; echo '</div>'; echo '<div class="col-md-5 right" style="background: url(' . get_field('servingurl', $post->ID) . ') center center / cover;"></div>'; echo '<div class="col-md-1"></div>'; echo '<div class="clear"></div>'; endif; } wp_reset_query(); } die(); }how can i load my ajax to work with filter please ?
Topic: Custom Query and template
Hi,
Just bought and read the docs but i’m not following here.
This is a piece from one template file in my theme:
<section id="events-lijst"> <?php // the query $options = array( 'post_type' => 'event', 'posts_per_page' => 20, 'order' => 'ASC', 'meta_key' => 'taal', 'meta_value' => 'Nederlands' ); $query = new WP_Query( $options ); ?> <?php if ( $query->have_posts() ) : ?> <div class="container"> <div class="eventrow"> <?php while ( $query->have_posts() ) : $query->the_post(); ?> <div class="panel panel-default"> <div class="panel-heading"> <h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2> </div> <div class="event-foto-sectie"> <?php $uitgelichte_afbeelding = get_field( 'uitgelichte_afbeelding' ); ?> <?php if ( $uitgelichte_afbeelding ) { ?> <a href="<?php the_permalink(); ?>"><img src="<?php echo $uitgelichte_afbeelding['url']; ?>" class="event-featured-img" alt="<?php echo $uitgelichte_afbeelding['alt']; ?>" /></a> <?php } ?> </div> <div class="panel-body"> <?php $dateformatstring = "l d F, Y"; $unixtimestamp = strtotime(get_field('datum')); ?> <p><strong>Datum: </strong> <?php echo date_i18n($dateformatstring, $unixtimestamp); ?><br/><strong>Locatie: </strong><?php the_field( 'locatie' ); ?></p> <span class="eventuitleg"><?php the_excerpt(); ?></span> <p class="bekijkevent"><strong><a href="<?php the_permalink(); ?>">Bekijk dit evenement</a> >></strong></p> </div> </div> <?php endwhile; ?> </div> </div> <?php wp_reset_postdata(); ?> <?php else : ?> <section class="section-padding"> <div class="container"> <div class="row-centered"> <div class="col-md-12 col-centered"> <strong>Sorry, geen enkel event geprogrammeerd op dit ogenblik...</strong> </div> </div> </div> </section> <?php endif; ?> </section><!-- event lijst -->I want to put a row at the top where my query underneath is filterd on custom fields (using ACF)
Topic: How to implement?
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.