Support

Account

Forum Replies Created

  • I think i figured out this problem with this.

    It all boils down to WordPress’s get_posts() function and some of the names used for custom post types by bbpress.

    bbpress uses ‘reply’ and ‘topic’, they probably should be namespaced. When ACF calls get_posts() inside the relationship code it uses the ‘acf/get_post_types’ filter to retrieve all post types setup for the them. It then passes in those post types as an array to the WordPress get_posts() function as the ‘post_type’ parameter.

    WordPress does not like either ‘reply’ or ‘topic’ being passed in there. WordPress will only give you the results when logged in. When logged out if either of those names are passed into get_posts via the post_type parameter you get nothing back.

    So really this is either something that needs to be fixed with core WordPress or bbpress should change the name of their post types.

    But until that happens people that use both plugins in their theme can chuck something like this in their functions file:-

    add_filter('acf/get_post_types', 'my_acf_post_type_filter', 20, 3);
    
    function my_acf_post_type_filter ($post_types) {
        $exclude = array('topic', 'reply');
    
        // exclude
        foreach( $exclude as $p )
        {
            unset( $post_types[ $p ] );
        }
    
        return $post_types;
    }

    The other option would be for Elliot to just stick those two post type names as things to exclude in his get_post_types() function in the core of ACF to just sidestep this issue altogether.

Viewing 1 post (of 1 total)