Custom Fields
Re-Envisioned
Support MB Relationships Relationship 'Post' edit screen even if 'post_type' => 'product' only

This topic contains 5 replies, has 3 voices, and was last updated by  Matthias Nettekoven 4 months ago.

  • Creator
    Topic
  • #13350
    Resolved
    andrewrhyand
    Participant

    When register this relationship shouldn’t setting 'post_type' => 'product' in the 'to' make it so that meta box only appear for the product cpt?

    For some reason the ‘Saves’ meta box also appears on the normal post edit screen as well.

    MB_Relationships_API::register([
        'id' => 'users_to_products',
        'from' => [
            'object_type' => 'user',
            'meta_box' => [
                'title' => 'Saves',
                'field_title' => 'Select Products',
            ],
        ],
        'to' => [
            'object_type' => 'post',
            'post_type' => 'product',
            'meta_box' => [
                'title' => 'Saved By',
                'context' => 'side',
                'empty_message' => 'No users',
            ],
        ],
    ]);
Viewing 5 replies - 1 through 5 (of 5 total)
  • Author
    Replies
  • #13627

    Matthias Nettekoven
    Participant

    Hi,

    having the same issue. Were you able to solve this?

    #13634

    Anh Tran
    Keymaster

    Hi guys,

    I guess this problem occur because the MB User Meta plugin is not active. It’s required to make relationship from “user”. Can you please check that?

    #13640

    Matthias Nettekoven
    Participant

    Hi,

    I’m not using the user relations at all.

    I’m just having relations between post custom terms and custom post types. Which I assume is the reason for the behavior.

    So I have custom taxonomy which I added to “Posts”. Since I need the same taxonomy all over different Custom Post Types, I made a relation between them. Example:

    MB_Relationships_API::register( array(
                'id'   => 'events_to_units',
                'from' => array(
                    'object_type' => 'term',
                    'taxonomy'    => 'units'
                ),
                'to'   => array(
                    'post_type' => 'events',
                    'meta_box' => array(
                        'title' => 'Add Unit'
                    )
                ),
            ) );

    Now there is a select “Event” Relation Meta box below each post. But I never added a relation between post and CPT.

    Hope that helps to understand my issue.

    #13650

    Anh Tran
    Keymaster

    Hi Matthias,

    Did you activate the MB Term Meta extension? It’s required to set relationships with terms.

    #13712

    Matthias Nettekoven
    Participant

    Hi,

    thanks that was it 🙂 Appreciate your help.

Viewing 5 replies - 1 through 5 (of 5 total)

You must be logged in to reply to this topic.