因此,我使用post对象,它允许我根据标题搜索自定义帖子类型。我要做的是通过自定义字段搜索自定义帖子类型,并返回自定义字段值。目前,我的函数中有以下代码。php文件:-
function my_post_object_query( $args, $field, $post_id ) {
// Get the search text
$the_search = $args[\'s\'];
// Remove it so ACF won\'t search the posts based on title
unset($args[\'s\']);
// Search based on custom field
$args[\'meta_key\'] = \'short_title\';
$args[\'meta_value\'] = $the_search;
$args[\'meta_compare\'] = \'LIKE\';
// return
return $args;
}
// filter for a specific field based on it\'s name
add_filter(\'acf/fields/post_object/query/name=product\', \'my_post_object_query\', 10, 3);
这允许我使用自定义字段进行搜索,但返回的值仍然是the\\u title()。如何将返回的值更改为相同的自定义字段;short\\u标题谢谢