0
我想過濾後對象字段上列出的頁面以僅顯示數組中的頁面。嘗試過濾ACF後對象以僅顯示某些頁面
我設法讓它使用關係字段來工作。但是,我需要進行反向查詢並需要使用post對象字段。
這是用於關係字段查詢過濾器
function my_relationship_query($args, $field, $post)
{
// increase the posts per page
$args['post__in'] = array(32,14); //works!
return $args;
}
// filter for a specific field based on it's name
add_filter('acf/fields/relationship/query/name=where_used','my_relationship_query', 10, 3);
這裏的代碼是我嘗試使用該職位對象查詢的代碼,無論我做什麼或改變它不會改變導致下拉菜單(所有頁面始終列在下拉菜單中)。
function my_post_object_query($args, $field, $post_id) {
// only show children of the current post being edited
$args['post__in'] = array(32,14);;
// return
return $args;
}
// filter for a specific field based on it's name
add_filter('acf/fields/post_object/query/name=where_used', 'my_post_object_query', 10, 3);
在此先感謝您的幫助
保羅