Custom Fields
Re-Envisioned
Support MB Relationships Warning on metabox for relationship to multiple CPTs

  • Creator
    Topic
  • #16461
    Resolved Aart Jan van der Linden
    Participant

    Hi!
    I’m getting this:
    Warning: strtolower() expects parameter 1 to be string, array given in [...]/wp-includes/formatting.php on line 2126

    This happens when I register a relationship to multiple CPT’s and don’t hide the meta_box.

        MB_Relationships_API::register([
            'id' => 'xxxx',
            'from' => [
                'post_type' => 'cpt1',
                'meta_box' => [
                    'hidden'    => true,
                ]
            ],
            'to' => [
                'post_type' => ['cpt2','cpt3','cpt4','cpt5'],
                'meta_box' => [
                    'title' => 'xxxx',
                    'field_title' => 'xxxx',
                ],
            ],
        ]);
    

    The warning disappears when I add 'hidden' => true to the ‘to’ section, or when I use only one cpt in the second section.

    Any thoughts?

    Thanx!

Viewing 3 replies - 1 through 3 (of 3 total)
  • Author
    Replies
  • #16476
    Anh Tran
    Keymaster

    Hi,

    When creating relationship, please set the post_type parameter to a single post type. It doesn’t accept multiple post types.

    #16762

    Hi,

    thanx for your reply. Sorry to be stubborn, but it seems to work (apart from the warning). It would be great if it could be supported this way, because it would make the relationships between multiple cpt’s much cleaner. Is there a technical/design reason not to support it this way?

    Also: in similar situations like in get_posts(), WordPress works the same, allowing both single post_types and arrays of post_types.

    Best,

    Aart Jan

    #16764
    Anh Tran
    Keymaster

    Hi Aart Jan,

    Is there a technical/design reason not to support it this way?

    Yes, it’s designed to work for single post type at the moment. Making it works for multiple post types at once is not supported at the moment, due to a lot of technical problems.

Viewing 3 replies - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.