-
Search Results
-
Topic: ACF Field in results
Hi,
How can I show an ACF Field in the results?
I use the code the_field(‘field’) in the code but it’s not working.
Thanks.
We’ve recently upgraded to the latest version of Search and Filter pro.
The old version was setup by someone else. We are using a custom template to display search results, with custom taxonomies for the product pages.
The filtering no longer works, and we are struggling to get multiple pages for results as the we can’t seem to figure our the “loop” for display our results with the information attached.
Archive page below:
<?php get_header(); ?>
<div class=”page-header available”>
<div class=”container”>
<?php echo do_shortcode(‘[searchandfilter id=”79″]’); ?>
</div></div>
<div class=”full-width-content”>
<div class=”container”>
<div class=”sculpture-intro”><h1 style=”font-size:x-Large;”>Sculpture Collection
</h1><br></div>
<div class=”row”><div class=”col-md-12″>
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<article class=” sculpture_post”>
<div class=”archive-thumb”>“> <?php the_post_thumbnail( ‘archive-thumb’ ); ?>
</div><h1 class=”archive”>“><?php the_title(); ?></h1>
<p><?php the_category( ‘, ‘ ); ?></p>
<div class=”artistt-archive”>
<?php$term = get_field(‘artist’);
if( $term ): ?>
<p>by <?php echo $term->name; ?></p>
<?php endif; ?>
</div><p><?php the_field(‘price’); ?></p>
<?php
$term = get_field(‘size’);
if( $term ): ?>
<p>size: <?php echo $term->name; ?></p>
<?php endif; ?>
</article>
<?php endwhile; else: ?>
<br>
<div class=”no-result”>
<h1>sorry! no sculptures match your criteria</h1>
<br>
Reset Search
</div><?php endif; ?>
</div>
</div>
<?php get_footer(); ?>
Hi,
I have a site using Genesis Recipe Pro theme. I have a custom loop, that loops through a custom post type. This post type also has a custom taxonomy.
Everything works fine, until I try and filter by that taxonomy. The initial selection works. The query updates… But then, if I try and select any other checkbox, or unselect the chosen selection, it refreshes the page (correctly) but doesn’t change anything, including the checkbox still being selected. It is happening in 2 separate places:
https://sunsetsewaneed.wpengine.com/equipment-resources
https://sunsetsewaneed.wpengine.com/ingredients/Note that it works fine within the main WP archive loop using the WP categories taxonomy:
https://sunsetsewaneed.wpengine.com/food-2/
I have tried disabling all plugins. There is no caching. The form is added via a sidebar widget.
Here is my code:
$_terms = get_terms( array('product_category') ); $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; $term_slug = $term->slug; $_posts = new WP_Query( array( 'post_type' => 'product_resources', 'search_filter_id' => 2406, 'posts_per_page' => 12, 'paged' => $paged )); if( $_posts->have_posts() ) : echo '<div class="flexbox">'; while ( $_posts->have_posts() ) : $_posts->the_post(); ?> <div class="flexbox-column"> <div class="fourty-width"> <a target="_blank" href="<?php the_field('affiliate_link');?>"><img src="<?php the_field('product_image');?>"></a> </div> <div class="sixty width"> <h2 class="entry-title"><a href="<?php the_field('affiliate_link');?>"><?php the_title(); ?></a></h2> <p><?php the_field('product_description');?></p> <a href="<?php the_field('affiliate_link');?>" class="affiliate-link" target="_blank">Get It</a> </div> </div> <?php endwhile; $total_pages = $_posts->max_num_pages; if ($total_pages > 1){ $current_page = $_posts->query_vars['paged']; echo '<div class="pagination">'; if(strpos($_SERVER['REQUEST_URI'], '_sft_resource_category') !== false) { echo paginate_links(array( 'base' => get_pagenum_link(1) . '%_%', 'format' => '&sf_paged=%#%', 'current' => max( 1, $current_page ), 'total' => $total_pages, 'prev_text' => __('« prev'), 'next_text' => __('next »'), )); } else { echo paginate_links(array( 'base' => get_pagenum_link(1) . '%_%', 'format' => '?sf_paged=%#%', 'current' => max( 1, $current_page ), 'total' => $total_pages, 'prev_text' => __('« prev'), 'next_text' => __('next »'), )); } echo '</div>'; } wp_reset_postdata(); echo '</div>'; endif;This is the result of the GET
Array ( [_sfm_condition] => Used [_sfm_fuel] => Diesel [_sfm_loa_feet] => 0 100 [_sfm_price] => 0 150000 )This is the stringvars after converting the between value (ignore -)
Used – Diesel – 0,100 – 0,150000This is the result of the args
Array ( [meta_query] => Array ( [relation] => AND [0] => Array ( [key] => condition [value] => Used [compare] => = ) [1] => Array ( [key] => fuel [value] => Diesel [compare] => = ) [2] => Array ( [key] => loa_feet [value] => Array ( [0] => 0,100 ) [compare] => BETWEEN ) [3] => Array ( [key] => price [value] => Array ( [0] => 0,150000 ) [compare] => BETWEEN ) ) )this is the args construct
$args = array(
‘meta_query’ => array(
// ‘post_type’ => ‘post’,
// ‘category’ => 1165,
‘relation’ => ‘AND’,
array(
‘key’ => ‘condition’,
‘value’ => $condition,
‘compare’ => ‘=’
),
array(
‘key’ => ‘fuel’,
‘value’ => $fuel,
‘compare’ => ‘=’
),
array(
‘key’ => ‘loa_feet’,
‘value’ => array($nloa),
‘compare’ => ‘BETWEEN’,
),
array(
‘key’ => ‘price’,
‘value’ => array($nprice),
‘compare’ => ‘BETWEEN’,
),
// ‘key’ => ‘price’,
// ‘orderby’ => ‘meta_value_num’,
// ‘order’ => ‘DESC’
)
);
but even though in the search terms I am effectively asking for ‘give me everything’ (all test data is used and diesel currently)$custom_posts = get_posts($args);
returns
Array()I have used DRY in that I am re-using the default layout list code as in
foreach($custom_posts as $post) : setup_postdata($post);
and in there I am using ACF as in the_field(‘condition’) for data outputBUT even sending the form result to a different page it looks like
$custom_posts = get_posts($args); isn’t working?Hope you can shed some light on what is going on here
Hey guys,
we have about 50 results in total and 20 per page. The results page shows that there are 3 pages (before applying any filters) which is correct. But you can’t click through them before applying a filter.
Here’s the link to the website:
https://hypnoschool.de/therapeutenliste/uebersichtHeres ist the code fom my results.php
<?php /** * Search & Filter Pro * * Sample Results Template * * @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 this file is called directly, abort. if ( ! defined( 'ABSPATH' ) ) { exit; } if ( $query->have_posts() ) { ?> <?php echo $query->found_posts; ?> Ergebnisse gefunden<br /> Seite <?php echo $query->query['paged']; ?> von <?php echo $query->max_num_pages; ?><br /> <div class="pagination"> <div class="nav-previous"><?php next_posts_link( 'Vorherige Ergebnisse', $query->max_num_pages ); ?></div> <div class="nav-next"><?php previous_posts_link( 'Weitere Ergebnisse' ); ?></div> <?php /* example code for using the wp_pagenavi plugin */ if (function_exists('wp_pagenavi')) { echo "<br />"; wp_pagenavi( array( 'query' => $query ) ); } ?> </div> <?php while ($query->have_posts()) { $query->the_post(); ?> <div class="therapeut"> <p><a href="<?php the_permalink(); ?>"><?php the_field("name"); ?></a></p> <?php if ( has_post_thumbnail() ) { echo '<p>'; the_post_thumbnail("thumbnail"); echo '</p>'; } ?> <p><?php the_field("land"); ?></p> <p><?php the_field("plz_&_stadt"); ?></p> </div> <hr /> <?php } ?> Seite <?php echo $query->query['paged']; ?> von <?php echo $query->max_num_pages; ?><br /> <div class="pagination"> <div class="nav-previous"><?php next_posts_link( 'Vorherige Ergebnisse', $query->max_num_pages ); ?></div> <div class="nav-next"><?php previous_posts_link( 'Weitere Ergebnisse' ); ?></div> <?php /* example code for using the wp_pagenavi plugin */ if (function_exists('wp_pagenavi')) { echo "<br />"; wp_pagenavi( array( 'query' => $query ) ); } ?> </div> <?php } else { echo "Keine Ergebnisse gefunden"; } ?>Topic: ACF posts not displaying
Hello. I am trying to create a range filter on my site.
I have used the meta field in Search and Filter pro and linked it to a number field in ACF. I have set the results to display “Custom” and created a custom template which runs my ACF loop. I have used the code below to pull the posts through as per the custom documentation.
<?php $args = array('post_type' => 'workspace'); $args['search_filter_id'] = 183; $query = new WP_Query($args); ?> <?php if ( have_posts() ) : while ( $the_query->have_posts() ) : $the_query->the_post(); ?> /// My results <?php endwhile; else: ?> Sorry no posts. <?php endif; ?> This shows no results. I have also tried using the "as an archive" option and it is still not working... Here is all my code, should it be of help . <?php get_header(); ?> <?php /* Template Name: Property Results */ ?> <header> <div class="container"> <div class="section group"> <div class="col span_8_of_12"> content </div> </div> <!--Close .section--> </div> <!--Close .container --> </header> <!--Close header--> <div class="container"> <?php echo do_shortcode('[searchandfilter id="183"]'); ?> </div> <div class="full-width lgrey-bg"> <div class="container"> <div class="section group property-promo-wrapper"> <?php $args = array('post_type' => 'workspace'); $args['search_filter_id'] = 183; $query = new WP_Query($args); ?> <?php if ( have_posts() ) : while ( $the_query->have_posts() ) : $the_query->the_post(); ?> <div class="col span_6_of_12 property-promo"> <?php if( have_rows('images') ): ?> <div class="owl-carousel owl-promoproperty"> <?php while( have_rows('images') ): the_row(); $image = get_sub_field('image'); ?> <div><img />"></div> <?php endwhile; ?> </div> <!-- Close .property-promo .images --> <?php endif; ?> <div class="info"> <h4><strong><?php the_title( '' ); ?></strong> <br>– <strong><?php the_field('location'); ?></strong></h4> <?php if( have_rows('nearby_stations') ): ?> <ul class="rail"> <?php while( have_rows('nearby_stations') ): the_row(); $station_name = get_sub_field('station_name'); $distance_to_workspace = get_sub_field('distance_to_workspace'); $type_of_station = get_sub_field('type_of_station'); ?> <li class="<?php echo $type_of_station; ?>"><?php echo $station_name; ?> <?php echo $distance_to_workspace; ?></li> <?php endwhile; ?> </ul> <!-- Close .rail --> <?php endif; ?> <div class="stats"> <div class="section group"> <div class="col span_7_of_12"> <ul> <li>size<br><strong><?php the_field('square_foot'); ?> sq ft</strong></li> <li>per month<br><strong>£<?php the_field('price_per_month'); ?></strong></li> <li>people<br><strong><?php the_field('people'); ?></strong></li> <li>per year<br><strong>£<?php the_field('price_per_year'); ?></strong></li> </ul> </div> <div class="col span_5_of_12"> <p><a>">Download brochure</a></p> <a href="#"><div class="button button_a">Enquire</div></a> </div> </div> <!-- Close .section --> </div> <!-- Close .stats --> </div> <!-- Close .info --> </div> <!-- Close .property-promo col --> <?php endwhile; else: ?> <h2>We have no properties to show at the moment</h2> <p>Please subscribe to our mailing list to be the first to hear about new workspaces.</p> <br> <a href=""><div class="button button_a">Enquire</div></a> <?php endif; ?> </div> <!--section --> </div> <!--container --> </div> <!--full-width --> <?php get_footer(); ?>Pagination doesn’t” work properly
Hello. I am using search and Filter pro and having problem with pagination.
It seems to work fine but when I go back to page 1, only page 1 doesn’t have the link(doesn’t have href).
And it happens only PC view, if I check with SP, it works just fine.Here is My code.
(*I use original code for pagination, but if tried to use WP-PageNavi(same as your template of results.php) Page 1 doesn’t work either.)[results.php]
<?php if ($query->have_posts()) : ?> <?php while ($query->have_posts()) { $query->the_post(); ?> <a href="<?php the_permalink(); ?>" class="sresult"> <?php if (has_post_thumbnail()) { echo '<p class="sresult-thumb">'; the_post_thumbnail(); echo '</p>'; } ?> <h2 class="sresult-ttl"><?php the_title(); ?></h2> <p class="sresult-name"><?php the_field('interview_name'); ?> </p> <?php $fields = get_field_objects($post_id); $dir_array = $fields["interview_occupation"]["choices"]; $check = get_field('interview_occupation'); $value = $check[0]; ?> <p class="sresult-job"><?php echo $dir_array[$value]; ?></p> </a><!-- /.sresult --> <?php } ?> <div class="spagination"> <?php if ( function_exists( 'pagination' ) ) : pagination( $query->max_num_pages, get_query_var( 'paged' ) ); endif; ?> </div><!-- /.spagination --> <?php else : ?> <div class="snoresult"> <p>No results</p> </div><!-- /.snoresult --> <?php endif; ?> </div><!-- /. search-filter-results -->[functions.php]
function pagination( $pages, $paged, $range = 2, $show_only = false ) { $pages = ( int ) $pages; $paged = $paged ?: 1; //表示テキスト $text_first = "« FIRST"; $text_before = "PREV"; $text_next = "NEXT"; $text_last = "LAST »"; if ( $show_only && $pages === 1 ) { echo '<div class="pagination"><span class="current pager">1</span></div>'; return; } if ( $pages === 1 ) return; if ( 1 !== $pages ) { echo '<div class="pagination"><span class="page_num">Page ', $paged ,' of ', $pages ,'</span>'; if ( $paged > $range + 1 ) { // FIRST echo '<a href="', get_pagenum_link(1) ,'" class="first js_redirect_to_pagenum_link">', $text_first ,'</a>'; } if ( $paged > 1 ) { // PREV echo '<a href="', get_pagenum_link( $paged - 1 ) ,'" class="prev js_redirect_to_pagenum_link">', $text_before ,'</a>'; } for ( $i = 1; $i <= $pages; $i++ ) { if ( $i <= $paged + $range && $i >= $paged - $range ) { // $paged +- $range 以内であればページ番号を出力 if ( $paged === $i ) { echo '<span class="current pager">', $i ,'</span>'; } else { echo '<a href="', get_pagenum_link( $i ) ,'" class="pager js_redirect_to_pagenum_link">', $i ,'</a>'; } } } if ( $paged < $pages ) { // NEXT echo '<a href="', get_pagenum_link( $paged + 1 ) ,'" class="next js_redirect_to_pagenum_link">', $text_next ,'</a>'; } if ( $paged + $range < $pages ) { // LAST echo '<a href="', get_pagenum_link( $pages ) ,'" class="last js_redirect_to_pagenum_link">', $text_last ,'</a>'; } echo '</div>'; } }The website is my client site so I cannot give you the link. But if you provide me a contact address that I can send you directly or hide this topic somehow, I can give you the link of testsite.
Regards,