Home › Forums › Backend Issues (wp-admin) › How can I dynamically filter the list of posts? › Reply To: How can I dynamically filter the list of posts?
Thanks!
Making some headway, here is my new test code:
function my_post_object_query( $args, $field, $post )
{
$args['cat'] = wp_get_post_categories($post->ID);
echo '<pre>';
print_r($args);
echo '</pre>';
//die;
return $args;
}
// filter for a specific field based on it's key
add_filter('acf/fields/post_object/query/key=field_524f02159316d', 'my_post_object_query', 10, 3);
This returns the following array:
Array
(
[numberposts] => -1
[post_type] => post_images
[orderby] => title
[order] => ASC
[post_status] => Array
(
[0] => publish
[1] => private
[2] => draft
[3] => inherit
[4] => future
)
[suppress_filters] =>
[sort_column] => menu_order, post_title
[sort_order] => ASC
[cat] => Array
(
[0] => 5
)
)
you can see the cat id is getting added, but the results that come back in the dropdown are not filter to only include posts form catid 5
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.