Changing default title of relationships box

Support General Changing default title of relationships boxResolved

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #28072
    @mindspark@mindspark
    Participant

    I'm making some relationships between several CPTs and custom Taxonomies. When we make these relationships - we see the box on the right side of the screen and it says 'Connected From' or 'Connected To'. See here: https://snipboard.io/vxMdPb.jpg

    I would like to change these titles. Is that possible? and if so, can I assign unique titles to different boxes so they don't all read the same?

    thanks for your help.

    #28081
    Long NguyenLong Nguyen
    Moderator

    Hi,

    Yes, it is possible. You can add the setting meta box title to the from or to array. For example:

    'from'  => [
        'object_type'   => 'post',
        'post_type'     => 'post',
        'meta_box'      => [
            'title' => 'Custom connected'
        ]
    ],
    'to'    => 'page',

    Read more on the documentation https://docs.metabox.io/extensions/mb-relationships/#syntax

    If you use the builder, you can click on the tab Meta Box, screenshot https://share.getcloudapp.com/P8u5qJYl.

    #28098
    @mindspark@mindspark
    Participant

    Your code example isolates the type of relationship (posts to posts, terms to posts, etc). But what if I wanted to isolate by specific relationship?

    Example, I have many 'post to post' relationships, but I need the 'Connect to/from' box to have a different title for each relationship.

    Like this -

    (post to post relationship #1) Events to Venues => from 'Connected to' to 'Linked Venues'
    (post to post relationship #2) Venues to Work Zones => from 'Connected to' to 'Assigned Work Zones'

    #28105
    Long NguyenLong Nguyen
    Moderator

    Hi,

    You can create many relationships between objects as you want: post types, users, terms.
    For post object, specific by post_type setting.
    For term object, specific by taxonomy setting.

    add_action( 'mb_relationships_init', function() {
        MB_Relationships_API::register( [
            'id'    => 'events_to_venues',
            'from'  => [
                'object_type'   => 'post',
                'post_type'     => 'event',
                'meta_box'      => [
                    'title' => 'Link to Venues'
                ]
            ],
            'to'    => [
                'object_type'   => 'post',
                'post_type'     => 'venue',
                'meta_box'      => [
                    'title' => 'Assigned Events'
                ]
            ],
        ] );
    } );
    add_action( 'mb_relationships_init', function() {
        MB_Relationships_API::register( [
            'id'    => 'venues_to_workzone',
            'from'  => [
                'object_type'   => 'post',
                'post_type'     => 'venue',
                'meta_box'      => [
                    'title' => 'Link to Work Zones'
                ]
            ],
            'to'    => [
                'object_type'   => 'post',
                'post_type'     => 'workzone',
                'meta_box'      => [
                    'title' => 'Link to Venues'
                ]
            ],
        ] );
    } );
    add_action( 'mb_relationships_init', function () {
        MB_Relationships_API::register( [
            'id'   => 'categories_to_workzone',
            'from' => [
                'object_type' => 'term',
                'taxonomy'    => 'category',
                'meta_box'      => [
                    'title' => 'Assigned Work Zones'
                ]
            ],
            'to'    => [
                'object_type'   => 'post',
                'post_type'     => 'workzone',
                'meta_box'      => [
                    'title' => 'Link to Categories'
                ]
            ],
        ] );
    } );
    

    Please read more on the documentation
    https://docs.metabox.io/extensions/mb-relationships/#terms-to-posts
    https://docs.metabox.io/extensions/mb-relationships/#users-to-posts

    #28109
    @mindspark@mindspark
    Participant

    thanks! that's easy - and thanks for building in those parameters!

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