Search Results With CPT & ACF fields

Forums › Forums › Search & Filter Pro › Search Results With CPT & ACF fields

Viewing 9 posts – 1 through 9 (of 9 total)
  • Anonymous
    #244930

    Hi, I have a custom post type and I’m using ACF with that CPT. I need to create dropdown search based on one of the fields (county) that returns all the ACF fields associated. Can this be done with a shortcode or do I need to create a custom archive template with a custom loop? I tried to look through the documentation and the forum but was having trouble finding relevant info.

    Thanks!

    Trevor
    #244955
    This reply has been marked as private.
    Anonymous
    #244965
    This reply has been marked as private.
    Trevor
    #245092

    I had to rebuild the cache. You also had a setting for Relevanssi enabled, but with no search box and that plugin not installed anyway, that may also have been an issue.

    Anonymous
    #245126

    Yeah, I turned it on just because I was trying everything. I don’t see it working now though, not sure what rebuilding the cache did. Were you able to get the ACF fields to return in the results too?

    Trevor
    #245136

    This is what I see. To get the fields to show in the results you would need to code them into the template, using this guide:

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

    The extra code would likely need to look like this:

    <?php $county = get_field('county');
    if( $county ) { ?>
    <div class="county-field">County: <?php echo $county; ?></div>
    <?php } ?>
    Anonymous
    #245147
    This reply has been marked as private.
    Anonymous
    #245149
    This reply has been marked as private.
    Trevor
    #245153

    Thanks for letting me know. I will close this thread for now.

Viewing 9 posts – 1 through 9 (of 9 total)
Search & Filter Support
Privacy Overview

This website uses cookies so that we can provide you with the best user experience possible. Cookie information is stored in your browser and performs functions such as recognising you when you return to our website and helping our team to understand which sections of the website you find most interesting and useful.

We also use cookies to store items in your cart as well as allowing your to login on the site.

You can adjust all of your cookie settings by navigating the tabs on the left hand side.

By continuing to use this site, you also agree to our Privacy Policy.