Support

Account

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?