Support

Account

Home Forums Backend Issues (wp-admin) Show private posts in acf relationship field

Helping

Show private posts in acf relationship field

  • Hi,

    I would like for Private posts to be available to select in the Relationship field. I’ve tried to hook it with the following and although it seems to work (if I change ‘private’ to ‘draft’ it show the draft posts) the private posts just won’t show.

    function my_acf_result_query( $args, $field, $post )
    {
        // eg from https://codex.wordpress.org/Class_Reference/WP_Query#Custom_Field_Parameters
        $args['post_status'] = 'private';        
        return $args;
    }
    
    // acf/fields/relationship/result - filter for every field
    add_filter('acf/fields/relationship/query', 'my_acf_result_query', 10, 3);

    Is there any work around for this ?

    Thanks,
    Fred

  • Hi @aggelos,

    Thanks for the post.

    I have just tried this out on my end and the filter is pulling the private posts as expected.

    I am however running the latest Pro version 5.3.7.

Viewing 2 posts - 1 through 2 (of 2 total)

The topic ‘Show private posts in acf relationship field’ is closed to new replies.