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?
Hi There
I am switching back to the Relationship field as it seems to sort of handle the cat filter.
Here is my code
function my_relationship_query( $args, $field, $post )
{
// increase the posts per page
//$args['cat'] = wp_get_post_categories($post->ID);
$args['cat'] = '3,5';
return $args;
}
// filter for a specific field based on it's key
add_filter('acf/fields/relationship/query/key=field_524f02159316d', 'my_relationship_query', 10, 4);
using 3,5 works, but wp_get_post_categories($post->ID) does not work, just displays the loading icon.
Also – Is it possible to limit the number of items that can be added from left to right to only 1?
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.