最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

search results to show individual ACF fields from inside custom posts

programmeradmin3浏览0评论

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');
发布评论

评论列表(0)

  1. 暂无评论