search results to show individual ACF fields from inside custom posts

by henry puttick   Last Updated June 13, 2019 17:08 PM

In need of some help. I have my search results showing the custom post type with all the ACF fields inside. What I want is the search result to show the ACF singularly with a field name of file_name that is a text field and file field file_pdf. together they would be one result from any given amount of posts from the user. I can't seem to understand the way to code this. I'm currently using relevanssi plugin. I'm struggling with the idea of filtering just those two fields to show in the results.

function wpb_search_filter($query)
    global $current_user;
    if ($query->is_search && !is_admin())
        $query->set('author', $current_user->ID);
    // $query->set( 'post_type', array( 'pricing', 'attachment' ) );
    $query->set('meta_query', array(
        'key'       => 'file_pdf',
        'value'     => $query->query['s']
    return $query;
add_filter('pre_get_posts', 'wpb_search_filter');

Related Questions

Advanced search form with multiple custom fields

Updated May 07, 2018 22:08 PM

Custom Post Type filter by Author custom ACF field

Updated February 06, 2018 14:08 PM

Check ACF fields in foreach custom taxonomy

Updated April 23, 2015 22:03 PM

Query between dates using ACF Date Picker fields

Updated April 26, 2016 08:03 AM