Forums Forums Search Search Results for 'get_field'

Viewing 10 results - 31 through 40 (of 188 total)
  • Author
    Search Results
  • #234105

    Anonymous
    Inactive

    So i was able to use your documentation to grab the following query output: However, when i attempt to call the field _sfm_city it does not display anything. This is a Meta Key, does that matter? My attempt to display it is listed below

    
    Array
    (
        [_sft_specialties] => Array
            (
                [name] => specialties
                [singular_name] => Specialty
                [all_items_label] => All Items
                [type] => taxonomy
                [active_terms] => Array
                    (
                        [0] => Array
                            (
                                [id] => 355
                                [name] => Test Matter Type
                                [value] => test-matter-type
                                [count] => 1
                            )
    
                    )
    
            )
    
        [_sft_providers-category] => Array
            (
                [name] => Categories
                [singular_name] => Categories
                [all_items_label] => Categories
                [type] => taxonomy
                [active_terms] => Array
                    (
                        [0] => Array
                            (
                                [id] => 68
                                [name] => Patent Search
                                [value] => patent-search
                                [count] => 1
                            )
    
                    )
    
            )
    
        [_sft_operatingcountries] => Array
            (
                [name] => Operation Countries
                [singular_name] => Operating Countries
                [all_items_label] => All Operating Countries
                [type] => taxonomy
                [active_terms] => Array
                    (
                        [0] => Array
                            (
                                [id] => 145
                                [name] => Denmark
                                [value] => denmark
                                [count] => 1
                            )
    
                    )
    
            )
    
        [_sfm_city] => Array
            (
                [name] => 
                [singular_name] => 
                [all_items_label] => 
                [type] => post_meta
                [active_terms] => Array
                    (
                        [0] => Array
                            (
                                [name] => HARARE
                                [value] => HARARE
                            )
    
                    )
    
            )
    
    )

    `<?php
    //Get a single fields values using labels
    //replace 1526 with the ID of your search form
    global $searchandfilter;
    $sf_current_query = $searchandfilter->get(1902)->current_query();
    echo $sf_current_query->get_field_string(“_sft_city”);

    ?>


    Anonymous
    Inactive

    Hi,
    I’ve searched as long as possible in the forum.
    I’ve read the documentation.

    The ajax form search fields and reset, works well.
    But I can’t get infinite scrolls to work.

    I’ve tryed with shortcode. I’ve put the shortcode in the WP classic editor. I’ve copied results.php in a subfolder of my theme (that is elementor hello theme) and I pasted in, the code of the results-infinite-scroll.php template.
    In the settings the result url is filled etc etc.
    Nothing. Scrolling nothing happens.

    Then I’ve tryed with custom setting. I’ve set a custom template in my theme with the code of the results-infinite-scroll.php template customized.
    In the settings the result url is filled etc etc.
    Ajax container = #main
    Pagination Type is set to infinite scroll; show loading icon checkbox is checked, but it’s not loaded.
    Post result selector = .search-results-item (but I’ve tryed without it, too)
    Infinite Scroll Container: = empty (but I’ve tryed with #search-filter-results-list, too)
    I’ve tryed all the other fields of the Ajax Pagination setting section, but nothing.
    I’ve deactivated all plugin except ACF Pro, Custom post type UI and S&F Pro of course. Nothing
    I’ve changed the theme with a default one. Nothing.

    The page is on a live web site that I’m developing. I can give the url but not publicly

    Thanks in advance for your help

    My custom template code:

    <?php
    /*
    Template Name: Eventi
    */
    get_header(); 
    ?>
    <style>
    .content {
        width:1440px;
        margin:0 auto;
        padding:20px;
    }
    .search-results-wrapper {
        display:flex;
        flex-wrap: wrap;
    }
    .search-results-item {
      /*flex: 1 0 21%;*/
      padding: 20px;
      display: flex;
      flex-direction: column;
      flex-basis: 25%;
    }
    .content-wrapper {
      flex: 1;
    }
    .post-thumb {
        height:300px;
        width:100%;
        background-position:center;
        background-size:cover;
        border-radius: 0 80px 40px 80px;
        border: 1px solid #15255E;
    }
    .post-thumb .term {
        display:inline-block;
        padding:5px 20px;
        background-color:#ccc;
        color:#FFF;
        min-width:200px;
        text-align:center;
        font-size: 20px;
        font-weight: 500;
    }
    .post-content {
        display:none;
        font-size:1rem;
      color:#010326;
      padding-top:20px;
      width:100%;
    }
    .post-title {
        color: #009cd3;
        font-size: 28px;
        margin-top:30px;
    }
    .post-event-date,
    .post-event-place {
        font-size: 16px;
        font-weight: 400;
        color: #009cd3;
    }
    
    .search-results-wrapper .btn-wrapper {
        margin-top:30px;
    }
    .search-results-wrapper .toggle_btn {
        width:100px;
    }
    .search-results-wrapper .btn-hover-last {
        width:75px;
    }
    .search-results-wrapper .btn-hover-first {
        margin-right:40px;
    }
    .search-results-wrapper .btn-hover-wrapper {
      text-align:left;  
      position:relative;
      padding-right:20px;
      display:inline-block;
    }
    
    .search-results-wrapper .toggle-wrapper:after {
      content:"\f067";
      font-size: 16px;
      top: 0px;
      right: 0px;
      position: absolute;
      -webkit-transition: all .5s ease-out;
      -moz-transition: all .5s ease-out;
      -o-transition: all .5s ease-out;
      transition: all .5s ease-out;
      display: inline-block;
      font-style: normal;
      font-variant: normal;
      text-rendering: auto;
      -webkit-font-smoothing: antialiased;
      font-family: 'FontAwesome';
      color:#15255e;
    }
    .search-results-wrapper .toggle-wrapper.active:after {
      transform: rotate(-180deg);
      content:"\f068";
      color:#009ad2;
    }
    .search-results-wrapper .btn-hover-wrapper a
    {
      display:block;
      position:relative;
      cursor:pointer;
    }
    .search-results-wrapper .btn-hover-wrapper img
    {
       transition: opacity .25s ease-in-out;
       -moz-transition: opacity .25s ease-in-out;
       -webkit-transition: opacity .25s ease-in-out;
    }
    .search-results-wrapper .btn-hover-last {
        padding:0;
    }
    .search-results-wrapper .btn-hover-last a {
      transform: translateY(-3px);
    }
    .search-results-wrapper .btn-hover-wrapper .hover-image
    {
      position:absolute;
      top:0px;
      left:0px;
      opacity:0;
       transition: opacity .25s ease-in-out;
       -moz-transition: opacity .25s ease-in-out;
       -webkit-transition: opacity .25s ease-in-out;
    }
    
    .search-results-wrapper .btn-hover-wrapper:hover img
    {
     opacity:0; 
    }
    
    .search-results-wrapper .btn-hover-wrapper:hover .hover-image
    {
     opacity:1; 
    }
    
    </style>
    
    	
    	<div class="content">
    	
    		<div class="inner-content">
    
    			<main class="main" role="main" id="main">
    			    
    				
    				<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
    
                        <article id="post-<?php the_ID(); ?>" <?php post_class(''); ?> role="article" itemscope itemtype="http://schema.org/WebPage">
                        						
                        	<header class="article-header"><meta http-equiv="Content-Type" content="text/html; charset=utf-8">
                        		<h1 class="page-title"><?php the_title(); ?></h1>
                            </header> <!-- end article header -->
    
                            <section class="entry-content" itemprop="text">
                        	    <?php the_content(); ?>
                        	</section> <!-- end article section -->
                        
                        </article> <!-- end article -->
                        
                     <?php endwhile; endif; ?>
                     
                    <?php wp_reset_query(); ?>
    
                     
                        
                	<div>
                		<?php echo do_shortcode('[searchandfilter id="1675"]'); ?>
                	</div>
    
                        <?php
                        
                        $args = array('post_type' => 'eventi');
                        $args['search_filter_id'] = 1675;
                        $query = new WP_Query($args);
                        
                        if ( $query->have_posts() ) {
                        ?>
                        
                        Found <?php echo $query->found_posts; ?> Results<br />
                        
                        	<div class="search-results-wrapper" id="search-filter-results-list">
                            	<?php
                            	while ($query->have_posts())
                            	{
                            		$query->the_post();
                            		$content = get_the_content();
                            		?>
                            		<div class="search-results-item search-filter-result-item">
                            			
                            			<div class="content-wrapper">
                                		    <?php 
                                				if ( has_post_thumbnail() ) :
                                				    $featured_img_url = get_the_post_thumbnail_url(get_the_ID(),'medium-large'); 
                                		    ?>
                                				<div class="post-thumb" style="background-image:url(<?=$featured_img_url ?>)">
                                				    <?php 
                                                        $terms = get_the_terms( $post->ID, 'tipologia' ); 
                                                        foreach($terms as $term) :
                                                    ?>
                                                            <span class='term' style="background-color:<?php the_field('tax_tipologia_color', 'tipologia' . '_' . $term->term_id) ?>">
                                                              <?php echo $term->name; ?>
                                                            </span>
                                                    <?php
                                                        endforeach;
                                                    ?>
                                				</div>
                                			<?php 
                                			    endif;
                                			?>
                                			<h2 class="post-title"><?php the_title(); ?></h2>
                                			<div class="post-event-date">
                                			    <span class="from-date"><?php the_field("start_date"); ?></span>
                                			    <?php 
                                			        if ( get_field("end_date") ) :
                            		            ?>
                                			            <span class="to-date"> - <?php the_field("end_date"); ?></span>
                                			    <?php       
                                			        endif;
                                			    ?>
                                			</div>
                                			<div class="post-event-place"><?php the_field("luogo"); ?></div>
                                        </div>
                                        
                                        <div class="btn-wrapper">
                                            <div class="btn-hover-wrapper toggle-wrapper btn-hover-first">
                                              <a class="toggle_btn" data-id="post-<?php the_ID(); ?>">  
                                                <img src="https://supernovae.kreas.it/wp/wp-content/uploads/2019/12/Scopri-di-piu-2.png" alt="Scopri di piu">
                                                <img src="https://supernovae.kreas.it/wp/wp-content/uploads/2019/12/Scopri-di-piu_over.png" class="hover-image" alt="Scopri di piu over">
                                              </a>
                                            </div>
                                            <div class="btn-hover-wrapper btn-hover-last">
                                              <a href="<?php the_field("event_url"); ?>" target="_blank" title="Scopri di piu">
                                                <img src="https://supernovae.kreas.it/wp/wp-content/uploads/2019/11/vai-al-sito-e1575911625135.png" alt="Vai al sito">
                                                <img src="https://supernovae.kreas.it/wp/wp-content/uploads/2019/11/vai-al-sito-over-e1575911641927.png" class="hover-image" alt="Vai al sito">  
                                              </a>
                                            </div>
                                            <div class="post-content toggle-content" id="post-<?php the_ID(); ?>">
                                                <?=$content ?>
                                            </div>
                                        </div>
                                        
                            		</div>
                            		
                        		<?php
                            	}
                            	?>
                        	</div>
                        <?php
                        }
                        else
                        {
                        	?>
                        	<div class='search-filter-results-list' data-search-filter-action='infinite-scroll-end'>
                        		<span>Non sono stati trovati eventi</span>
                        	</div>
                        	<?php
                        }
                        ?>
    				
    			    					
    			</main> <!-- end #main -->
    			
    			
    
    			
    
    		</div> <!-- end #inner-content -->
    
    	</div> <!-- end #content -->
    
    <script>
    jQuery(document).on('click', ".toggle_btn", function(event){
        var post_id = jQuery(this).attr("data-id");
        jQuery(this).parent().toggleClass('active');
        jQuery("#" + post_id).toggle(500);
        event.preventDefault();
    });    
    </script>
    <?php get_footer(); ?>

    Trevor
    Participant

    I have looked at the file and indeed the structure of the HTMl is that of a non-infinite scroll results.php file.

    It will need to be modified/edited to be usuable for infinite scroll.

    If you look in the plugin folder, there is a templates sub folder with examples of normal pagination and infinite scroll, to help you re-code it.

    For me it might look like this instead?

     * @package   Search_Filter
     * @author    Ross Morsali
     * @link      https://searchandfilter.com
     * @copyright 2018 Search & Filter
     *
     * Note: these templates are not full page templates, rather
     * just an encaspulation of the your results loop which should
     * be inserted in to other pages by using a shortcode - think
     * of it as a template part
     *
     * This template is an absolute base example showing you what
     * you can do, for more customisation see the WordPress docs
     * and using template tags -
     *
     * http://codex.wordpress.org/Template_Tags
     *
     */
     
    if ( $query->have_posts() )
    {
        ?>
         
        <!-- ***********************************************************************************************************
        products
        ************************************************************************************************************* -->
        <div class="found">Found <?php echo $query->found_posts; ?> Results<br /></div>
         
        <div class="search-filter-results-list products-list-area">
            <?php
            while ($query->have_posts())
            {
                $query->the_post();
                 
                ?>
     
                <div class="search-filter-result-item products-list-item w_addt_image">
                    <a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>">
     
                        <!-- 1st image from gallery on hover -->
                        <?php $addt_image = get_field('nr_additional_images'); if( $addt_image ): ?>
                        <div class="products-list-item-img-wrap addt_image">
                            <img src="<?php echo $addt_image[0]["sizes"]["large"]; ?>">
                        </div>
                        <?php else: ?>
                        <div class="products-list-item-img-wrap addt_image">
                            <?php the_post_thumbnail(); ?>
                        </div>
                        <?php endif; ?>
     
                        <?php $product_thumb = get_the_post_thumbnail(''); if( !empty($product_thumb) ): ?>
                        <div class="products-list-item-img-wrap">
                            <?php the_post_thumbnail(); ?>
                        </div>
                        <?php else: ?>
                        <div class="products-list-item-img-wrap">
                            <img src="http://placehold.it/300x300/e5e5e5/ffffff?text=Image+Not+Available" alt="">
                        </div>
                        <?php endif; ?>
     
                    </a>
                    <div class="details">
                        <!-- <div class="product-material-and-collection"><?php the_field('nr_material'); ?> | <?php the_field('nr_collection'); ?></div> -->
                        <div class="product-material-and-collection">
                        <?php
                            $field1 = get_field_object('nr_material');
                            $materials = get_field('nr_material'); // array of selected values
                            $resultstr = array();
                            foreach ($materials as $material) {
                                $resultstr[] = $field1['choices'][ $material ];
                            }
                            echo implode(", ",$resultstr);
                        ?>
                         |
                        <?php
                            $field = get_field_object('nr_collection');
                            $value = $field['value'];
                            $label = $field['choices'][ $value ];
                        ?>
                        <?php echo $label; ?>
     
                            <?php the_favorites_button($post_id, $site_id); ?>
                        </div>
                        <div class="product-name">
                            <a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
                        </div>
                    </div>
                </div>
                 
                <?php
            }
            ?>
        </div>
         
        <?php
    }
    else
    {
    	?>
    	<div class='search-filter-results-list' data-search-filter-action='infinite-scroll-end'>
    		<span>End of Results</span>
    	</div>
    	<?php
    }
    ?>
    #230834

    Anonymous
    Inactive

    “I can see what you are doing. You have on the page two archives which are S&F form Results shortcodes. The forms themselves are being used only to pre-filter, with no actual form.”

    > Correct

    You are using custom results.php files (numbered the same as the forms). If using the standard results.php template for both results, there is not an issue?

    > It works with the default listing.

    If form #780 uses the standard results.php, but form #781 uses the custom one, it works?

    > It does.

    If form #780 uses the custom results.php and form #781 uses the standard results.php, what happens then?

    > It does NOT work.

    I’m using the default loop “while ($query->have_posts())” and then using filters to remove some of the results with get_field. That’s why I’m not using any limist to the results (they list from 105 to 300 results).

    If both results are using a custom result.php, the second (781) is not even going into the “if ($query->have_posts())” loop.

    #230647

    Anonymous
    Inactive

    This is my code, using a shortcode and a query. The display results option is Custom and using ajax.

    <?php echo do_shortcode ('[searchandfilter id="5437"]'); ?>
    
    <div class="clearfix"></div>
    <div class="filtro-cars" data-wow-duration="1s" data-wow-delay="0.3s">
    
    	<?php $args = array('post_type' => 'renting');
    	$args['search_filter_id'] = 5437;
    	$query = new WP_Query($args);?>
    
    	<?php if ( $query->have_posts() ) : while ( $query->have_posts() ) : $query->the_post(); // run the loop ?>
    	<div class="car main-car col-xs-12 col-sm-12 col-md-6 wow fadeIn no-padding" data-wow-duration="0.4s" data-wow-delay="0.3s">
    		<a class="redirectClick" href="<?php the_permalink(); ?>">
    			<div class="item item-price" >
    				<div class="car-shadow">
    					<div class="image"><?php the_post_thumbnail( 'car-related' ); ?></div>
    				    <div class="data">
    					    <div class="row">
    						    <div class="col-md-7 col-lg-8">
    						    	<span class="marca"><?php the_title (''); ?></span>
    						    	<span class="vehicle-finish"><?php the_field ('modelo'); ?></span>
    						    </div>
    						    <div class="col-md-5 col-lg-4">
    							    <div class="combustible hidden-xs hidden-sm">
    					    			<?php
    									$count = 0;
    									$your_repeater = get_field('caracteristicas');
    									if($your_repeater){
    									while( have_rows('caracteristicas') ): the_row();
    									$count++;
    									$my_field = get_sub_field('icono');
    									$my_content= get_sub_field('texto');
    									if ($count == 4) { ?>
    										<img width="14" src="<?php echo get_template_directory_uri(); ?>/inc/img/front/<?php echo $my_field; ?>.svg" /> <?php echo $my_content; ?>
    									<?php }
    									endwhile;  
    									}
    									?>
    							    </div>
    						    </div>
    					    </div>
    					    <div class="row">
    						    <div class="col-sm-7">
    							    <div class="precio-card"><?php the_field ('precio'); ?>€/mes<br>
    							    	<span class="iva-incluidos">IVA incluido</span>
    							    </div>
    						    </div>
    						    <div class="col-sm-5 info">
    							    <div class="kilometros">
    								    <?php the_field ('km_anuales'); ?><span class="km-anuales">km anuales |</span>
    								</div>
    							    <div class="meses">
    								    <?php the_field ('meses'); ?><span class="meses">meses</span>
    								</div>
    						    </div>
    					    </div>
    				    </div>
    				</div>
    			</div>
    		</a>
    	</div>
    	<?php endwhile;
    	else: ?>
    	<div class="no-results">No hemos encontrado resultados, prueba con otros criterios de filtro.</div>
    	<?php endif; ?>
     
    	<?php wp_reset_query(); ?>
    
    </div>

    Anonymous
    Inactive

    The plugin doesn’t use get_post_meta function, it retrieves data by using the ACF API (actions and filters) and ACF get_field(). There is no data saved in the wp_postmeta table.
    That’s why I was thinking of intercepting the WP_Query somehow…


    Anonymous
    Inactive

    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!

    #230042

    Anonymous
    Inactive

    Hi Trevor, thanks for your quick thought.
    Yes,both settings for auto count are set to on.
    Hide empty is only for “choise” fields, and the first two settings are number fields. Hide empty is set to on for the third field.

    – Can it have something to do with the fact that I use 3 wp-queries?
    – I don’t see any effect from adding 'search_filter_id' => 153395, to the $args. How can I check if this is set right?

    Please see this page, where the only offer should disappear when the first filter is set to less than 3: https://fietspitstop.nl/product/yepp-fietszitje-achter-maxi-easyfit-achter-zwart/

    This is the most recent template code:

    <?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_the_terms( get_the_ID(), 'productgroep' )[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=""]'); ?>
    					<?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;
    
    echo "all merchants: ";
    print_r($all_merchants);
    
    //Get filtered merchants
    //wp_reset_postdata();
    //wp_reset_query();
    $args_offers = array(
        'post_type' => 'merchants',
        'search_filter_id' => 153395,
        'tax_query' => array(
            //'relation' => 'AND',
            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" id = "pdp-shopping-list">
    <br><?php
    echo "filtered merchants: ";
    print_r($filtered_merchants);
    ?>
    <br><?php
    echo "query 2: ";
    print_r($query2);
    ?>
    							<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 if ( have_posts() ) : 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; else : ?>
    	<p><?php esc_html_e( 'Geen producten gevonden.' ); ?></p>
    <?php endif; ?>
    						</div>
    <?php
    //wp_reset_postdata();
    //wp_reset_query();
    ?>
    
    				</div>
    			</div>
    		</main>
    	</section>
    </div>
    

    Thanks in advance.

    #229977

    Anonymous
    Inactive

    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
    //replace 1526 with 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!

    #229944

    Anonymous
    Inactive

    Hi,

    I have these taxonomies:
    – Product
    – Merchant
    – Merchant offer

    I 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 Oostenbrugge

Viewing 10 results - 31 through 40 (of 188 total)