Forums Forums Search & Filter Pro No Results Found With Filter

Viewing 8 posts - 1 through 8 (of 8 total)
  • Anonymous
    #218541

    I’m working on the filtering for this search but having an issue with taxonomy filtering. The taxonomy filter is showing the proper number of posts on the dropdown but when filter is chosen, the filter shows no results. I clicked on one individually to make sure it had the taxonomy and it did. The search function seems to work. It is just the taxonomy.

    Trevor
    #218566
    This reply has been marked as private.
    Anonymous
    #218654
    This reply has been marked as private.
    Trevor
    #218741
    This reply has been marked as private.
    Anonymous
    #219083
    This reply has been marked as private.
    Trevor
    #219117

    If you need to modify our results.php template the guide is here:

    https://searchandfilter.com/documentation/search-results/using-a-shortcode/#customising-the-results

    If you need to output the value of an ACF field, and give it a label, the code shown in this post might help:

    https://support.searchandfilter.com/forums/topic/output-acf-post-object-fields-in-results/#post-102009

    You may find other posts with snippets with this forum search:

    https://support.searchandfilter.com/forums/search/results.php+acf+get_field/

    Anonymous
    #220320

    Thanks! That worked well.
    Just out of curiosity, my code works but I have such a rudimentary understanding of PHP I only want the fields “image” and “business_description” to display if it exists. This is what I got. How can I add that in or is there some post I can look at to figure it out. `<?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() )
    {
    ?>
    <?php
    $header_link = the_field(‘business_website_address_url’);
    ?>

    <?php
    while ($query->have_posts())
    {
    $query->the_post();

    ?>

    <div>
    <h2><a href=”<?php the_field(‘business_website_address_url’); ?>”><?php the_title(); ?></a></h2>
    <div class=”desc”><img src=”<?php the_field(‘image’); ?>”><p><?php the_field(‘business_description’) ?></p></div>
    <p class=”details”> Website: <a href=”<?php the_field(‘business_website_address_url’); ?>” target=”_blank”><?php the_field(‘business_website_address_url’) ?></a></p>
    <p class=”details”> Phone: <a href=”tel:<?php the_field(‘phone’); ?>”><?php the_field(‘phone’) ?></a></p>
    <p class=”details”> Booth: <?php the_field(‘booth_number’) ?></p>

    </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( ‘More Exhibitors’, $query->max_num_pages ); ?></div>
    <div class=”nav-next”><?php previous_posts_link( ‘Previous Exhibitors’ ); ?></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”;
    }
    ?>`

    Trevor
    #220392

    So, if I understand you correctly, you want to conditionally show this part:

    <div class="desc"><img src="<?php the_field('image'); ?>”><p><?php the_field('business_description') ?></p></div>

    so, it would be this:

    <?php if (get_field('image')) {?>
    <div class="desc"><img src="<?php the_field('image'); ?>”><p><?php the_field('business_description') ?></p></div>
    <?php }?>

    This uses get_field to see if the image field has anything in it, and only outputs that bit if it does. I am assuming here that if the image exists, so will the description.

    I hope that helps?

Viewing 8 posts - 1 through 8 (of 8 total)