-
Search Results
-
Hello,
I am using ACF Custom Database Tables plugin that creates custom tables for ACF custom meta data. ACF Custom Database Tables uses ACF’s core API functions – get_field() and update_field() – to store/retrieve data from custom tables.
The fields for the Custom Post Type are created as usual with ACF, but then the plugin saves the data in a custom table, outside the normal WP post meta table.
I was wondering if I can use the SF Pro plugin for searching and filtering this custom table, maybe by altering the WP_Query?
The custom fields do not appear in the Post Meta table at all, and also not in the SF post meta search field.Regards!
Hello Trevor,
Thanks a lot for the hard work you guys put in this great S&F.
I have a question.
I try to get the filtered Categories shown above my filter results.
As in: Categories: (here the filtered terms).
I followed this advice: https://searchandfilter.com/documentation/accessing-search-data/And use now this code and get it in elementor with snippets:
//Get a multiple fields values by passing an array of field names
//replace1526with the ID of your search form
global $searchandfilter;
$sf_current_query = $searchandfilter->get(6890)->current_query();
echo $sf_current_query->get_fields_html(
array(“_sft_category”, “”)
);What I notice are two things:
1. with AJAX on, after the filter search, I need to refresh the page to get the code active/filled with the active terms
2. If Ajax is off, it is automatically updating ( I think due to reload page).Can you help me to get this working with Ajax on?
Thanks a lot in advance!Hi,
I have these taxonomies:
– Product
– Merchant
– Merchant offerI created a custom post template to make it possible to view all merchant offers for a product, with the possibility to filter on both merchant meta fields (review, payment methods..) as on merchant offer meta fields (price, delivery time..)
Now I see that the S&F Pro plugin shows filter options for every existing post instead of the current viewed product. When you see my code below (this is my very first php-code, so when it is looking strange, that’s why), do you have a hint how to show only filter options for the current viewed product?<?php /* * Template Name: Product * Template Post Type: post, page, product, item */ get_header(); ?> <?php $link = get_post_custom_values("link") [0]; $color = get_post_custom_values("kleur") [0]; //echo get_post_custom_values("product_group")[0]; ?> <div id="content" class="site-content"> <section id="primary" class="content-area"> <main id="main" class="site-main"> <article id="post-2" class="post-2 page type-page status-publish hentry entry"> <div class = "pdp-full-top"> <div class = "pdp-top-container entry-header"> <h1 class = "pdp-title"> <?php $brand = get_post_custom_values("brand") [0]; $line = get_post_custom_values("line") [0]; $type = get_post_custom_values("type") [0]; $variant = get_post_custom_values("variant_value") [0]; echo $brand . " " . $line . " " . $type . " " . $variant; ?> </h1> <div class = "pdp-image-container"><div class = "pdp-image-helper"></div><?php the_post_thumbnail(); ?> </div> <div class = "pdp-top-info-container"> <h2 class = "pdp-sub-title"> <?php $product_group = get_terms(array( 'taxonomy' => 'productgroep', 'hide_empty' => false, )) [0]->name; echo $product_group . ", " . $variant; ?> </h2> <h5 class = "pdp-choise-criteria">Keuzecriteria</h5> <div class = "pdp-price">Prijs vanaf ... </div> </div> </div> </div> <div class = "pdp-lister-container entry-content"> <?php //Filter area ?> <div class = "pdp-filter-container"> <?php echo do_shortcode('[searchandfilter id="165176"]'); ?> <?php echo do_shortcode('[searchandfilter id="153395"]'); ?> </div> <div class = "pdp-shopping-list-container"> <?php //Get all merchants $ean = get_field("ean"); $args_merchants = array( 'post_type' => 'merchant_offer', 'tax_query' => array( array( 'taxonomy' => 'ean', 'field' => 'slug', 'terms' => $ean, 'compare' => '=' ) , ) ); $offers = new WP_Query($args_merchants); $all_merchants = []; while ($offers->have_posts()): $offers->the_post(); $get_merchant = get_post_meta(get_the_ID() , 'merchant_id') [0]; array_push($all_merchants, $get_merchant); endwhile; //Get filtered merchants wp_reset_postdata(); wp_reset_query(); $args_offers = array( 'post_type' => 'merchants', 'search_filter_id' => 153395, 'tax_query' => array( 'relation' => 'OR', array( 'taxonomy' => 'merchant_id', 'field' => 'slug', 'terms' => $all_merchants, 'operator' => 'IN', ) , ) ); $query2 = new WP_Query($args_offers); $filtered_merchants = []; $post_id_by_merchant = []; while ($query2->have_posts()): $query2->the_post(); $get_filtered_merchant = get_post_meta(get_the_ID() , 'merchant_id') [0]; array_push($filtered_merchants, $get_filtered_merchant); $post_id_by_merchant[$get_filtered_merchant] = get_the_ID(); endwhile; //Get filtered offers by filtered merchants wp_reset_postdata(); wp_reset_query(); $args_filtered_offers = array( 'post_type' => 'merchant_offer', //add filter id somewhere here! 'search_filter_id' => 165176, 'tax_query' => array( 'relation' => 'AND', array( 'taxonomy' => 'ean', 'field' => 'slug', 'terms' => $ean, ) , array( 'taxonomy' => 'merchant_id', 'field' => 'slug', 'terms' => $filtered_merchants, ) , ) , ); $query3 = new WP_Query($args_filtered_offers); //Build shopping list ?> <div class = "pdp-shopping-list"> <div class = "row header"> <div class = "item"></div> <div class = "item">Winkel</div> <div class = "item">Reviews</div> <div class = "item">Basisprijs</div> <div class = "item">Totaalprijs</div> <div class = "item"></div> </div> <?php while ($query3->have_posts()): $query3->the_post(); setlocale(LC_MONETARY, 'nl_NL'); $current_merchant_id = $post->merchant_id; $stars = floatval(get_post_meta($post_id_by_merchant[$current_merchant_id], 'reviewsterren', true)); $review_amount = get_post_meta($post_id_by_merchant[$current_merchant_id], 'aantal_reviews', true); ?> <div class = "row"> <div class = "item logo"><?php echo get_the_post_thumbnail($post_id_by_merchant[$current_merchant_id]); ?></div> <div class = "name"><?php echo get_post_meta($post_id_by_merchant[$current_merchant_id], 'name', true) ?></div> <div class = "review-container"><div class="stars" style="--rating: <?php echo $stars ?>;" aria-label="Rating of this product is <?php echo $stars ?> out of 5."></div><div class = "reviews"><?php echo $review_amount . " reviews" ?></div></div> <div class = "item price-actual"><?php echo money_format("€%.2n", $post->price_actual); ?></div> <div class = "item price-total"><?php echo money_format("€%.2n", $post->total_price); ?></div> <div class = "item view"><button class = "button"><a href="<?php echo $post->link; ?>" target="blank">Bekijken</a></button> </div> </div> <?php endwhile; ?> </div> <?php wp_reset_postdata(); wp_reset_query(); ?> </div> </div> </main> </section> </div>Thanks again in advance.
Best regards,
Roeland van OostenbruggeHello,
I’m using the plugin in ajax and infinte scroll mode. Display method custom.
Displays random duplicates. Other pages appear when refreshing.And plugin display duplicated post:
http://i.epvpimg.com/ReXUbab.jpgSettings:
http://i.epvpimg.com/pEMPbab.pngTPL code:
<?php get_header();?> <div class="container"> <div class="row"> <div class="col-12"> <div class="cars-stock-banner"> <?php $image = get_field('car-stock-photo'); $size = 'full'; // (thumbnail, medium, large, full or custom size) if( $image ) { echo wp_get_attachment_image( $image, $size, '', array( "class" => "lazyload" ) ); } ?> <div class="cars-stock-banner__content text-center"> <?php if (have_posts()): while (have_posts()) : the_post(); ?> <?php the_content();?> <?php endwhile; ?> <?php endif; ?> </div> </div> </div> </div> </div> <div class="container"> <div class="row"> <div class="col-12"> <div class="cars-stock-filters"> <!-- <div class="js-cars-stock-filters-button cars-stock-filters__button"> <?php _e('Filtrowanie (opcjonalnie)', 'cupra');?> </div> --> <div class="cars-stock-filters__form"> <?php echo do_shortcode('[searchandfilter id="464"]');?> </div> </div> </div> </div> <?php $argsCars = array('post_type' => 'post'); $argsCars['search_filter_id'] = 464; $queryCars = new WP_Query($argsCars); ?> <div id="cars-stock-ajax"> <div class="cars-stock-infinite-scroll row"> <?php if ($queryCars->have_posts()): while ($queryCars->have_posts()) : $queryCars->the_post(); ?> <div class="col-12 col-sm-6 cars-stock-infinite-scroll-item"> <div class="row"> <div class="col-11"> <div class="cars-stock-item__img"> <a href="<?php the_permalink();?>"> <div class="cars-stock-item__location"> <span> <?php the_field('location_car');?> </span> </div> <?php $foto = get_field('photo_1') ?> <img src="<?php echo $foto['sizes']['large'] ?>" alt="<?php the_title(); ?>" /> </a> </div> </div> </div> <div class="row"> <div class="col-12 text-right"> <div class="cars-stock-item-info"> <a class="cars-stock-item-info__link" href="<?php the_permalink();?>" title="<?php _e('Zobacz więcej', 'cupra');?>"> <h3> <?php the_field('marka'); ?> <?php the_field('model'); ?> </h3> </a> <p class="cars-stock-item-info__price"> <?php the_field('cena_promocyjna'); ?> </p> <p class="cars-stock-item-info__parameters"> silnik: <?php the_field('pojemnosc_skokowa'); ?> <?php the_field('moc'); ?> </p> <p class="cars-stock-item-info__parameters"> skrzynia: <?php the_field('skrzynia'); ?> </p> <a class="cars-stock-item-info__more" href="<?php the_permalink();?>" title="<?php _e('Zobacz więcej', 'cupra');?>"> <?php _e('Zobacz więcej', 'cupra');?> </a> </div> </div> </div> </div> <?php endwhile; else:?> <span data-search-filter-action='infinite-scroll-end'><?php _e('Brak więcej wyników');?></span> <?php endif; ?> </div> </div> </div> <div class="pagination"> </div> <?php get_footer();?>Anyone can help me?
Topic: bug in select
i create search form, i use shortcode, i create page with my shortcode but the results not good,
i use like this:function select_artist_in_filter_page() { $args = array('post_type' => 'artist','posts_per_page' => -1); $my_query = new WP_query($args); if($my_query->have_posts()) { echo '<div class="elementor-container elementor-column-gap-default"> <div class="elementor-row"> <div class="elementor-element elementor-element-80b276a elementor-column elementor-col-100 elementor-top-column" data-element_type="column"> <div class="elementor-column-wrap elementor-element-populated"> <div class="elementor-widget-wrap"> <div class="elementor-element elementor-element-62b3681 elementor-grid-4 elementor-grid-tablet-4 elementor-grid-mobile-1 elementor-posts--thumbnail-top elementor-card-shadow-yes elementor-posts__hover-gradient elementor-widget elementor-widget-archive-posts" data-element_type="widget" data-widget_type="archive-posts.archive_cards"> <div class="elementor-widget-container"> <div class="elementor-posts-container elementor-posts elementor-grid elementor-posts--skin-cards elementor-has-item-ratio">'; while($my_query->have_posts()) { $my_query->the_post(); $custom = get_post_custom(get_the_ID()); $image = wp_get_attachment_image_src( get_post_thumbnail_id( $args->ID ), 'single-post-thumbnail' ); // the images for the artist echo '<article class="elementor-post elementor-grid-item post-170 artist type-artist status-publish has-post-thumbnail"> <div class="elementor-post__card"> <a class="elementor-post__thumbnail__link" href="'.get_permalink($args->ID).'"> <div class="elementor-post__thumbnail"><img height="150" src="'.$image[0].'" alt=""></div> </a> <div class="elementor-post__text"> <h3 class="elementor-post__title"> <a href="'.get_permalink($args->ID).'">'.get_field('artist_name').'</a> </h3> </div> <div class="elementor-post_meta-data" style="text-align: center; background: #d80159;"> <a class="elementor-post__read-more" href="tel:'.get_field('Artist_Phone').'">'.get_field('Artist_Phone', $args->ID).'</a> </div> <div class="elementor-post__meta-data"> <span class="elementor-post-avatar"> המלצות: '.get_comments_number($my_query->ID).' </span> </div> </div> </article>'; } echo '</div></div></div></div></div></div></div></div>'; wp_reset_postdata(); } } function select_artist_in_filter_page_reset() { // reset the loop ob_start(); select_artist_in_filter_page(); return ob_get_clean(); }but i not see the real options, i see all artist i need to see the artist with location i choose in fitlers:
https://mesibot.linuxisrael.co.il/filterresults/?_sft_location_artist=%d7%9b%d7%9c-%d7%94%d7%90%d7%a8%d7%a5
this is the urlway is not working ?