-
AuthorSearch Results
-
January 10, 2020 at 12:14 pm #230647
In reply to: Hide Posts if nothing is selected, then show them
AnonymousInactiveThis 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>
December 1, 2019 at 12:01 am #228131Topic: Display ACF custom fields in search results
in forum Search & Filter Pro
AnonymousInactiveHello –
Do you know what I’m doing wrong here?
I’m trying to display the two below ACF custom fields in my search results, but they don’t show up. What is the correct way to display them?Thanks!
name: employer Type: Relationship
name: salary Type: Text<?php the_field(’employer’); ?>
<?php the_field(‘salary’); ?>—-
<?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 ( $query->have_posts() )
{
?><h5 style=”#70757a”>Found <?php echo $query->found_posts; ?> Results<br /></h5>
Page <?php echo $query->query[‘paged’]; ?> of <?php echo $query->max_num_pages; ?><br /><div class=”pagination”>
<div class=”nav-previous”><?php next_posts_link( ‘Older posts’, $query->max_num_pages ); ?></div>
<div class=”nav-next”><?php previous_posts_link( ‘Newer posts’ ); ?></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=”job-search-results”>
<h2>“><?php the_title(); ?></h2>
<?php
if ( has_post_thumbnail() ) {
echo ‘<p>’;
the_post_thumbnail(“small”);
echo ‘</p>’;
}
?>
<div class=”search-results-employer”><h5>Employer Name: <?php the_field(’employer’); ?> </h5></div>
<div class=”search-results-employer”><h5>Salary: <?php the_field(‘salary’); ?> </h5></div>
<div class=”search-results-location”><h5><?php the_terms( 0, ‘city’); ?>, <?php the_terms( 0, ‘job_country’); ?></h5></div>
<div class=”search-results-skills”><h5>Skills: <?php the_terms( 0, ‘job_expertise’); ?> </h5></div>
<div class=”search-results-date”><h5><small><?php the_date(); ?></small></h5></div>
</div><hr />
<?php
}
?>
Page <?php echo $query->query[‘paged’]; ?> of <?php echo $query->max_num_pages; ?><br /><div class=”pagination”>
<div class=”nav-previous”><?php next_posts_link( ‘Older posts’, $query->max_num_pages ); ?></div>
<div class=”nav-next”><?php previous_posts_link( ‘Newer posts’ ); ?></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 “No Results Found”;
}
?>November 18, 2019 at 4:34 pm #226945In reply to: Infinite Scroll
AnonymousInactiveHi Trevor,
Apologies I’ve only just gotten around to trying this out, at the minute I get both messages coming up and I’m not entirely sure why, this is my results.php file.
<?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 ( $query->have_posts() )
{
?>
<div class=”flex-grid” data-aos=”fade-up”>
<?php
while ($query->have_posts()){
$query->the_post();
?>
<div class=”RoleGridWrapper col”>
<?php if( get_field(‘scrub_colour’) == ‘navy-blue’){ $postcolor = ‘#153F74’; } ?>
<?php if( get_field(‘scrub_colour’) == ‘cornflower-blue’){ $postcolor = ‘#5184C4’; } ?>
<?php if( get_field(‘scrub_colour’) == ‘mediterranean-blue’){ $postcolor = ‘#009EC7’; } ?>
<?php if( get_field(‘scrub_colour’) == ‘ocean-blue’){ $postcolor = ‘#64BFD4’; } ?>
<?php if( get_field(‘scrub_colour’) == ‘pale-sky-blue’){ $postcolor = ‘#97BADE’; } ?>
<?php if( get_field(‘scrub_colour’) == ‘dark-green’){ $postcolor = ‘#00A296’; } ?>
<?php if( get_field(‘scrub_colour’) == ‘mid-green’){ $postcolor = ‘#92CEBD’; } ?>
<?php if( get_field(‘scrub_colour’) == ‘silver-grey’){ $postcolor = ‘#ABAAAB’; } ?>
<div class=”roleContWrapper” style=”border-top: solid 10px <?php echo $postcolor; ?>”>
<div class=”cardTAB”>
<svg id=”scrubsIcon” data-name=”Layer 1″ xmlns=”http://www.w3.org/2000/svg” viewBox=”0 0 40 40″><title>Scrubs Icon</title><path style=”fill:<?php echo $postcolor; ?>;” d=”M39.6,7.22a40.13,40.13,0,0,0-13-4.12,1.11,1.11,0,0,0-1.39.72c-.43.91-.88,1.73-.92,1.8-1.72,3.28-3.54,6-4.18,6.19-.66-.16-2.48-2.63-4.25-5.63-.46-.76-.8-1.42-1.25-2.28a1.29,1.29,0,0,0-1.52-.77A37.94,37.94,0,0,0,.4,7.22a.78.78,0,0,0-.32,1L3.47,15a.79.79,0,0,0,.9.41l3.49-.87L6.78,36.11a.79.79,0,0,0,.79.83H32.43a.79.79,0,0,0,.79-.83L32.14,14.57l3.49.87a.79.79,0,0,0,.9-.41l3.39-6.78A.78.78,0,0,0,39.6,7.22Z”/></svg>
</div>
“>
<h3 class=”postHeader”><?php the_title(); ?></h3>
<div class=”postCATS”>
<?php
$categories = get_the_category();
$parentCatName = get_cat_name($categories[0]->parent);
if ( ! empty( $categories ) ) {
?>
<span class=”parentCAT”><?php echo esc_html( $parentCatName ); ?></span>
<?php
}
?>
</div>
<p class=”postIntro”><?php the_field(‘brief_role_description’); ?></p>
<div class=”readmoreWrapper”>
<p class=”postreadmore” href=”<?php the_permalink(); ?>”>Learn more</p>
</div>
</div>
</div>
<?php
}
}else{
//figure out which type of “no results” message to show
$message = “noresults”;
if(isset($query->query[‘paged’])) {
if($query->query[‘paged’]>1){
$message = “endofresults”;
}
}
if($message==”noresults”) {
?>
<div class=’search-filter-results-list’ data-search-filter-action=’infinite-scroll-end’>
<span>No Results Found</span>
</div>
<?php
} else {
?>
<div class=’search-filter-results-list’ data-search-filter-action=’infinite-scroll-end’>
<span>End of Results</span>
</div>
<?php
}
}
?>Can’t seem to see why it’s not choosing one or the other, the only way at the moment I can get it to find no results is to search for something that I know isn’t available.
Thank you
ScottNovember 11, 2019 at 11:30 am #226209In reply to: Results are not displaying
AnonymousInactiveHi Trevor,
Thanks for the reply.
OK. So I’m using a custom post type called ‘journal’. I would like to filter the archive page for this. The archive-journal.php file is below.
If it’s useful to speak with me, I’m in the UK
Thank you very much for your time, & have a good week.
Archive-journal.php:
<?php get_header(); ?> <div class="container"> <?php echo do_shortcode('[searchandfilter id="1928"]'); ?> <div class="journal-desktop-tables-gvs"> <div class="row journal-columns-gvs-row"> <div class="col-xl-1 col-lg-3 col-md-3 d-none d-xl-block col-sm-3 col-xs-3 journal-columns-gvs-title"> <!-- url --> <b>Link </b> </div> <div class="col-xl-3 d-none d-xl-block col-lg-6 col-md-6 col-sm-6 col-xs-6 journal-columns-gvs-title"> <!-- title --> <b> Title </b> </div> <div class="col-xl-2 d-none d-xl-block col-lg-3 col-md-3 col-sm-3 col-xs-3 journal-columns-gvs-title"> <!-- name --> <b> Author </b> </div> <div class="col-xl-1 d-none d-xl-block journal-columns-gvs-title journal-small-screen-hide"> <!-- volume --> <b> Volume</b> </div> <div class="col-xl-1 d-none d-xl-block journal-columns-gvs-title journal-small-screen-hide"> <!-- part --> <b> Part </b> </div> <div class="col-xl-1 d-none d-xl-block journal-columns-gvs-title journal-small-screen-hide"> <!-- month --> <b> Month </b> </div> <div class="col-xl-1 d-none d-xl-block journal-columns-gvs-title journal-small-screen-hide"> <!-- year --> <b> Year </b> </div> <div class="col-xl-2 d-none d-xl-block journal-columns-gvs-title journal-small-screen-hide"> <!-- keywords/tags --> <b> Keywords/Tags </b> </div> </div> <!-- close row --> </div> <!-- close journal-desktop-tables-gvs --> <?php $c = 0; ?> <?php if ( have_posts() ) { while ( have_posts() ) { the_post(); $c++; $data_target_collapsable_with_hash_gvs = '#'. get_the_ID(); //data target with hash $data_target_collapsable_without_hash_gvs = get_the_ID(); // data id without hash $data_aria_labelleby_heading_gvs = 'heading' . get_the_ID(); // aria-labelledby // echo ' ID with hash:' . $data_target_collapsable_with_hash_gvs; // echo ' ID withOUT hash:' . $data_target_collapsable_without_hash_gvs; // echo ' Arialabelledby:' . $data_aria_labelleby_heading_gvs; ?> <div class="row journal-columns-results-gvs"> <div class="col-xl-1 col-lg-3 col-md-3 col-sm-3 col-xs-3 journal-columns-gvs"> <!-- url --> <div class="mobile-only-journal-title-gvs"> LINK </div> <a href="<?php echo esc_url(the_field('url_journal')); ?>">Pdf link</a> </div> <div class="col-xl-3 col-lg-6 col-md-6 col-sm-6 col-xs-6 journal-columns-gvs"> <!-- title --> <div class="mobile-only-journal-title-gvs"> TITLE </div> <?php the_title(); ?> </div> <div class="col-xl-2 col-lg-3 col-md-3 col-sm-3 col-xs-3 journal-columns-gvs"> <!-- name --> <div class="mobile-only-journal-title-gvs"> AUTHOR </div> <?php the_field('first_name_journal'); ?> <?php the_field('surname_journal'); ?> </div> <!-- accordian start 1 --> <div id="accordion"> <div class="card"> <div class="card-header" id="heading-<?php the_ID(); ?>"> <h5 class="mb-0"> <button class="btn btn-link" data-toggle="collapse" data-target="#collapse-<?php the_ID(); ?>" aria-expanded="false" aria-controls="collapse-<?php the_ID(); ?>" id="collapsetbn"> <span class="not-collapsed-gvs"> See more information - click here </span> <span class="collapsed-gvs"> See less information </span> </button> </h5> </div> <div id="collapse-<?php the_ID(); ?>" class="collapse closed" aria-labelledby="heading-<?php the_ID(); ?>" data-parent="#accordion"> <div class="card-body"> <!-- accordian end 1 --> <div class="col-xl-1 col-lg-3 col-md-3 col-sm-3 col-xs-3 journal-columns-gvs "> <!-- volume --> <div class="mobile-only-journal-title-gvs"> VOLUME </div> <?php the_field('volume'); ?> </div> <div class="col-xl-1 col-lg-3 col-md-3 col-sm-3 col-xs-3 journal-columns-gvs"> <!-- part --> <div class="mobile-only-journal-title-gvs"> PART </div> <?php the_field('part_journal'); ?> </div> <div class="col-xl-1 col-lg-3 col-md-3 col-sm-3 col-xs-3 journal-columns-gvs"> <!-- month --> <div class="mobile-only-journal-title-gvs"> MONTH </div> <?php the_field('month_journal'); ?> </div> <div class="col-xl-1 col-lg-4 col-md-4 col-sm-4 col-xs-4 journal-columns-gvs"> <!-- year --> <div class="mobile-only-journal-title-gvs"> YEAR </div> <?php the_field('year_journal'); ?> </div> <div class="col-xl-2 col-lg-6 col-md-6 col-sm-6 col-xs-6 journal-columns-gvs"> <!-- keywords/tags --> <div class="mobile-only-journal-title-gvs"> KEYWORD TAGS </div> <div class="desktop-only-journal-content-gvs"> <?php $post_tags = get_the_tags(); if ( $post_tags ) { foreach( $post_tags as $tag ) { echo $tag->name . ', '; } } ?> </div> </div> <!-- accordian end 2 --> </div> </div> </div> </div> <!-- close #accordion --> <!-- accordian end 2 --> <div class="col-xl-1 col-lg-3 col-md-3 col-sm-3 col-xs-3 journal-columns-gvs desk-only "> <!-- volume --> <div class="mobile-only-journal-title-gvs"> VOLUME </div> <?php the_field('volume'); ?> </div> <div class="col-xl-1 col-lg-3 col-md-3 col-sm-3 col-xs-3 journal-columns-gvs desk-only "> <!-- part --> <div class="mobile-only-journal-title-gvs"> PART </div> <?php the_field('part_journal'); ?> </div> <div class="col-xl-1 col-lg-3 col-md-3 col-sm-3 col-xs-3 journal-columns-gvs desk-only "> <!-- month --> <div class="mobile-only-journal-title-gvs"> MONTH </div> <?php the_field('month_journal'); ?> </div> <div class="col-xl-1 col-lg-4 col-md-4 col-sm-4 col-xs-4 journal-columns-gvs desk-only "> <!-- year --> <div class="mobile-only-journal-title-gvs"> YEAR </div> <?php the_field('year_journal'); ?> </div> <div class="col-xl-2 col-lg-6 col-md-6 col-sm-6 col-xs-6 journal-columns-gvs desk-only "> <!-- keywords/tags --> <div class="mobile-only-journal-title-gvs"> KEYWORD TAGS </div> <div class="desktop-only-journal-content-gvs"> <?php $post_tags = get_the_tags(); if ( $post_tags ) { foreach( $post_tags as $tag ) { echo $tag->name . ', '; } } ?> </div> </div> </div> <!-- close row --> <?php } // end while } // end if ?> <!-- accordion end --> </div> <!-- close container --> <?php get_footer(); ?>
October 24, 2019 at 7:50 pm #224575In reply to: Display ACF fields info for each result
TrevorParticipantIt does, but you need access to the PHP template that the page sues to display the results. If you are using our Shortcode display results method, then follow the guidance here:
https://searchandfilter.com/documentation/search-results/using-a-shortcode/#customising-the-results
There are many examples of accessing ACF field data on the ACF forums on StackExchange. One difference is that you should use
get_the_ID()
to fetch the post ID of each post in the loop, and no reset is used.This search on our forums shows posts with some snippets:
https://support.searchandfilter.com/forums/search/the_field/
October 18, 2019 at 8:26 am #224050In reply to: Search results on home page
AnonymousInactiveHi!!! thanks for the support but I can’t make it work, where do I have to put that code??? If you can help me with this please.
This is my code:
<?php echo do_shortcode ('[searchandfilter id="2611"]'); ?> <?php $args = array('post_type' => 'coche'); $args['search_filter_id'] = 2611; $query = new WP_Query($args);?> <?php if ( $query->have_posts() ) : while ( $query->have_posts() ) : $query->the_post(); // run the loop ?> <div class="car col-sm-6 col-md-4 wow fadeIn" data-wow-duration="1s" data-wow-delay="0.3s"> <a class="redirectClick" href="<?php the_permalink(); ?>"> <div class="item item-price" > <span class="marca"><?php the_title (''); ?></span> <span class="vehicle-finish"><?php the_field ('modelo'); ?></span> <div class="image"><img src="<?php the_post_thumbnail_url( $size ); ?>" /></div> <span class="precio categoria"><?php the_field ('precio'); ?><span class="euros-al-mes">€/mes</span><span class="iva-incluido">IVA incluido</span></span> <div class="price-canceled"></div> <div class="row categorias"> <div class="col-xs-7 kilometros categoria"><img class="icono-kilometros" src="/wp-content/uploads/2019/04/icon-kilometer.svg" alt=""><?php the_field ('km_anuales'); ?><span class="km-anuales">km anuales</span></div> <div class="col-xs-5 meses categoria"><img class="icono-meses" src="/wp-content/uploads/2019/04/icon-clock.svg" alt=""><?php the_field ('meses'); ?><span class="meses">meses</span></div> </div> </div> </a> </div> <?php endwhile; ?> <?php endif; ?> <?php wp_reset_query(); ?>
October 17, 2019 at 10:46 am #223908In reply to: Search results on home page
AnonymousInactiveSorry, Now is working but I have to reload the home page to see the results, if I don’t reload page the results are all posts.
Any idea?
My code:
<?php echo do_shortcode ('[searchandfilter id="2611"]'); ?> <?php $args = array('post_type' => 'coche'); $args['search_filter_id'] = 2611; $query = new WP_Query($args);?> <?php if ( $query->have_posts() ) : while ( $query->have_posts() ) : $query->the_post(); // run the loop ?> <div <?php post_class('col-sm-4 col-md-4'); ?>> <a class="thumb_rel" href="<?php echo get_permalink();?>"><?php echo get_the_post_thumbnail();?></a> <span class="posted-on"> <span class="screen-reader-text">Publicado el </span> <time class="entry-date published"><?php echo get_the_date()?></time> <span class="tiempo_lectura">Tiempo de lectura <?php echo get_post_meta(get_the_ID(), 'tiempo_de_lectura', true)?>´</span> </span> <h4><a class="title_rel" href="<?php echo get_permalink();?>"> <?php if( get_field('titulo_listado_3_noticias') ) { ?> <?php the_field ('titulo_listado_3_noticias')?> <?php } else { ?> <?php the_title (); ?> <?php }?> </a> </h4> <hr class="linea-post"> <p><?php echo get_the_excerpt()?></p> </div> <?php endwhile; ?> <?php endif; ?> <?php wp_reset_query(); ?>
September 20, 2019 at 2:54 pm #221480In reply to: Infinite Scroll not working with WP Query
AnonymousInactiveI’ve replaced the first section as instructed and changed the Ajax container, but still no luck.
<?php /** * Created by PhpStorm. * User: jason * Date: 9/13/19 * Time: 9:48 AM * Template Name: Job Board */ get_header(); ?> <main id="job-board"> <section class="job-board-search job-search-menu background-image" style="background-image: url(<?php the_field('search_form_background_image', 'option'); ?>);"> <div class="site-container narrow"> <fieldset class="form big"> <?php echo do_shortcode('[searchandfilter id="218"]'); ?> </fieldset> </div> </section> <section class="main" id="jobs"> <div class="site-container"> <div class="ad top"></div> <div class="job-board-filters-wrapper"> <div id="job-board-filters" class="job-board-filters filter"> <h3 class="filters-heading">Job Filters</h3> <a id="job-filter-toggle"> <svg viewBox="0 0 24.76 24.76"> <path class="cls-1" d="M10,.5a.5.5,0,0,1,.5-.5h3.87a.5.5,0,0,1,.5.5V10h9.44a.5.5,0,0,1,.5.5v3.87a.5.5,0,0,1-.5.5H14.82v9.44a.5.5,0,0,1-.5.5H10.45a.5.5,0,0,1-.5-.5V14.82H.5a.5.5,0,0,1-.5-.5V10.45A.5.5,0,0,1,.5,10H10Z"/> </svg> </a> <div class="job-board-filters-inner"> <?php echo do_shortcode('[searchandfilter id="220"]'); ?> </div> </div> <div class="job-help"> <h3 class="filters-heading">Need Help?</h3> <a id="job-help-toggle"> <svg viewBox="0 0 24.76 24.76"> <path class="cls-1" d="M10,.5a.5.5,0,0,1,.5-.5h3.87a.5.5,0,0,1,.5.5V10h9.44a.5.5,0,0,1,.5.5v3.87a.5.5,0,0,1-.5.5H14.82v9.44a.5.5,0,0,1-.5.5H10.45a.5.5,0,0,1-.5-.5V14.82H.5a.5.5,0,0,1-.5-.5V10.45A.5.5,0,0,1,.5,10H10Z"/> </svg> </a> <div class="job-help-inner"> <ul> <li><a href="#">How to Post a Job </a></li> <li><a href="#">Help for Job Seekers </a></li> </ul> </div> </div> <div class="ad left"></div> </div> <?php $args['search_filter_id'] = 220; $query = new WP_Query($args); ?> <div class="job-board-results-wrapper"> <div class="mobile-table"> <?php if($query-> have_posts() ): ?> <table class="job-board-results grid"> <thead> <tr> <th class="title">Title & Organization</th> <th class="function">Job Function</th> <th class="type">Type</th> <th class="date">Date Posted </th> </tr> </thead> <tbody> <?php while($query->have_posts() ): ?> <?php $query->the_post(); ?> <?php $date = get_the_date('M j, Y'); $name = get_the_company_name(); $serviceAreas = get_the_terms( get_the_ID(), 'service_area' ); $jobFunctions = get_the_terms( get_the_ID(), 'job_function' ); $jobType = get_the_terms( get_the_ID(), 'job_type' ); ?> <tr class="single-job-result"> <td> <h4><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h4> <p><?php echo $name; ?></p></td> <td> <?php if($jobFunctions): ?> <ul> <?php foreach($jobFunctions as $jobFunction): ?> <li><?php echo $jobFunction->name; ?></li> <?php endforeach; ?> </ul> <?php endif; ?> </td> <td> <?php echo $jobType[0]->name; ?> </td> <td> <?php echo $date; ?> </td> </tr> <?php endwhile;?> <?php else: ?> <div data-search-filter-action='infinite-scroll-end'> <h4>No results found</h4> </div> <?php endif; wp_reset_postdata(); ?> </tbody> </table> </div> </div> </div> </section> </main> <?php get_footer();
September 20, 2019 at 2:04 pm #221472In reply to: Infinite Scroll not working with WP Query
TrevorParticipantI can see that you have echoed both forms on the page. This may cause issues (but not the one you describe I think).
I suspect that the problem is the HTML structure. I think it should start like this:
<?php /** * Created by PhpStorm. * User: jason * Date: 9/13/19 * Time: 9:48 AM * Template Name: Job Board */ get_header(); ?> <main id="job-board"> <section id="job-board-search" class="job-search-menu background-image" style="background-image: url(<?php the_field('search_form_background_image'); ?>);"> <div class="site-container narrow"> <fieldset class="form big"> <?php echo do_shortcode('[searchandfilter id="218"]'); ?> </fieldset> </div> </section> <section class="main" id="jobs"> <div class="site-container"> <div class="ad top"></div> <div class="job-board-filters-wrapper"> <div id="job-board-filters" class="job-board-filters filter"> <h3 class="filters-heading">Job Filters</h3> <a id="job-filter-toggle"> <svg viewBox="0 0 24.76 24.76"> <path class="cls-1" d="M10,.5a.5.5,0,0,1,.5-.5h3.87a.5.5,0,0,1,.5.5V10h9.44a.5.5,0,0,1,.5.5v3.87a.5.5,0,0,1-.5.5H14.82v9.44a.5.5,0,0,1-.5.5H10.45a.5.5,0,0,1-.5-.5V14.82H.5a.5.5,0,0,1-.5-.5V10.45A.5.5,0,0,1,.5,10H10Z"/> </svg> </a> <div class="job-board-filters-inner"> <?php echo do_shortcode('[searchandfilter id="220"]'); ?> </div> </div> <div class="job-help"> <h3 class="filters-heading">Need Help?</h3> <a id="job-help-toggle"> <svg viewBox="0 0 24.76 24.76"> <path class="cls-1" d="M10,.5a.5.5,0,0,1,.5-.5h3.87a.5.5,0,0,1,.5.5V10h9.44a.5.5,0,0,1,.5.5v3.87a.5.5,0,0,1-.5.5H14.82v9.44a.5.5,0,0,1-.5.5H10.45a.5.5,0,0,1-.5-.5V14.82H.5a.5.5,0,0,1-.5-.5V10.45A.5.5,0,0,1,.5,10H10Z"/> </svg> </a> <div class="job-help-inner"> <ul> <li><a href="#">How to Post a Job </a></li> <li><a href="#">Help for Job Seekers </a></li> </ul> </div> </div> <div class="ad left"></div> </div> <?php $args['search_filter_id'] = 220; $query = new WP_Query($args); ?> <div class="job-board-results-wrapper"> <div class="mobile-table"> <?php if($query-> have_posts() ): ?> <table class="job-board-results grid"> <thead> <tr> <th class="title">Title & Organization</th> <th class="function">Job Function</th> <th class="type">Type</th> <th class="date">Date Posted </th> </tr> </thead> <tbody> <?php while($query->have_posts() ): ?>
BUT, the ending parts to table and the job-board-results div might then need to be moved, I am not sure. I think the Ajax Container should be
.job-board-results-wrapper
September 19, 2019 at 3:08 pm #221368In reply to: Infinite Scroll not working with WP Query
AnonymousInactiveI echoed the shortcode. Full template file below for reference. (Thanks for your responses, by the way.)
<?php /** * Created by PhpStorm. * User: jason * Date: 9/13/19 * Time: 9:48 AM * Template Name: Job Board */ get_header(); ?> <main id="job-board"> <section id="job-board-search" class="job-search-menu background-image" style="background-image: url(<?php the_field('search_form_background_image'); ?>);"> <div class="site-container narrow"> <fieldset class="form big"> <?php echo do_shortcode('[searchandfilter id="218"]'); ?> </fieldset> </div> </section> <section class="main" id="jobs"> <div class="site-container"> <div class="ad top"></div> <div class="job-board-filters-wrapper"> <div id="job-board-filters" class="job-board-filters filter"> <h3 class="filters-heading">Job Filters</h3> <a id="job-filter-toggle"> <svg viewBox="0 0 24.76 24.76"> <path class="cls-1" d="M10,.5a.5.5,0,0,1,.5-.5h3.87a.5.5,0,0,1,.5.5V10h9.44a.5.5,0,0,1,.5.5v3.87a.5.5,0,0,1-.5.5H14.82v9.44a.5.5,0,0,1-.5.5H10.45a.5.5,0,0,1-.5-.5V14.82H.5a.5.5,0,0,1-.5-.5V10.45A.5.5,0,0,1,.5,10H10Z"/> </svg> </a> <div class="job-board-filters-inner"> <?php echo do_shortcode('[searchandfilter id="220"]'); ?> </div> </div> <div class="job-help"> <h3 class="filters-heading">Need Help?</h3> <a id="job-help-toggle"> <svg viewBox="0 0 24.76 24.76"> <path class="cls-1" d="M10,.5a.5.5,0,0,1,.5-.5h3.87a.5.5,0,0,1,.5.5V10h9.44a.5.5,0,0,1,.5.5v3.87a.5.5,0,0,1-.5.5H14.82v9.44a.5.5,0,0,1-.5.5H10.45a.5.5,0,0,1-.5-.5V14.82H.5a.5.5,0,0,1-.5-.5V10.45A.5.5,0,0,1,.5,10H10Z"/> </svg> </a> <div class="job-help-inner"> <ul> <li><a href="#">How to Post a Job </a></li> <li><a href="#">Help for Job Seekers </a></li> </ul> </div> </div> <div class="ad left"></div> </div> <div class="job-board-results-wrapper"> <div class="mobile-table"> <table class="job-board-results grid"> <thead> <tr> <th class="title">Title & Organization</th> <th class="function">Job Function</th> <th class="type">Type</th> <th class="date">Date Posted </th> </tr> </thead> <tbody> <?php $args['search_filter_id'] = 220; $query = new WP_Query($args); if($query-> have_posts() ): ?> <?php while($query->have_posts() ): ?> <?php $query->the_post(); ?> <?php $date = get_the_date('M j, Y'); $name = get_the_company_name(); $serviceAreas = get_the_terms( get_the_ID(), 'service_area' ); $jobFunctions = get_the_terms( get_the_ID(), 'job_function' ); $jobType = get_the_terms( get_the_ID(), 'job_type' ); ?> <tr class="single-job-result"> <td> <h4><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h4> <p><?php echo $name; ?></p></td> <td> <?php if($jobFunctions): ?> <ul> <?php foreach($jobFunctions as $jobFunction): ?> <li><?php echo $jobFunction->name; ?></li> <?php endforeach; ?> </ul> <?php endif; ?> </td> <td><?php echo $jobType[0]->name; ?></td> <td><?php echo $date; ?></td> </tr> <?php endwhile;?> <?php else: ?> <div data-search-filter-action='infinite-scroll-end'> <h4>No results found</h4> </div> <?php endif; wp_reset_postdata(); ?> </tbody> </table> </div> </div> </div> </section> </main> <?php get_footer();
-
AuthorSearch Results
-
Search Results
-
Hello –
Do you know what I’m doing wrong here?
I’m trying to display the two below ACF custom fields in my search results, but they don’t show up. What is the correct way to display them?Thanks!
name: employer Type: Relationship
name: salary Type: Text<?php the_field(’employer’); ?>
<?php the_field(‘salary’); ?>—-
<?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 ( $query->have_posts() )
{
?><h5 style=”#70757a”>Found <?php echo $query->found_posts; ?> Results<br /></h5>
Page <?php echo $query->query[‘paged’]; ?> of <?php echo $query->max_num_pages; ?><br /><div class=”pagination”>
<div class=”nav-previous”><?php next_posts_link( ‘Older posts’, $query->max_num_pages ); ?></div>
<div class=”nav-next”><?php previous_posts_link( ‘Newer posts’ ); ?></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=”job-search-results”>
<h2>“><?php the_title(); ?></h2>
<?php
if ( has_post_thumbnail() ) {
echo ‘<p>’;
the_post_thumbnail(“small”);
echo ‘</p>’;
}
?>
<div class=”search-results-employer”><h5>Employer Name: <?php the_field(’employer’); ?> </h5></div>
<div class=”search-results-employer”><h5>Salary: <?php the_field(‘salary’); ?> </h5></div>
<div class=”search-results-location”><h5><?php the_terms( 0, ‘city’); ?>, <?php the_terms( 0, ‘job_country’); ?></h5></div>
<div class=”search-results-skills”><h5>Skills: <?php the_terms( 0, ‘job_expertise’); ?> </h5></div>
<div class=”search-results-date”><h5><small><?php the_date(); ?></small></h5></div>
</div><hr />
<?php
}
?>
Page <?php echo $query->query[‘paged’]; ?> of <?php echo $query->max_num_pages; ?><br /><div class=”pagination”>
<div class=”nav-previous”><?php next_posts_link( ‘Older posts’, $query->max_num_pages ); ?></div>
<div class=”nav-next”><?php previous_posts_link( ‘Newer posts’ ); ?></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 “No Results Found”;
}
?>