build custom meta boxes for soccer matches

Support MB Conditional Logic build custom meta boxes for soccer matches

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #14088
    sadiq ahmedsadiq ahmed
    Participant

    hello

    i try to build mini website that i can add every match on new post and i want to use meta boxes .

    my idea is :
    editor first choose the league (ex : italy , spain , england ... etc) then the second box the select box with all team show (this is for team1) then same for team 2 , i don't want use deferent field for each league ,

    -2-
    can i get field value from API ? like i add (ID-field) and when i fill it with match ID from the API the other fields fill via API like , start time , location , country , stadium ... etc

    #14091
    Anh TranAnh Tran
    Keymaster

    Hi Sadiq,

    Regarding the first question, I think you can do that with MB Group. You can create a repeatable group with fields: league, team 1, team 2, etc.

    Regarding the 2nd question, yes, you can get field value with helper functions or shortcode.

    #14094
    sadiq ahmedsadiq ahmed
    Participant

    hi

    thank you for the reply ,, can you explain more ? i read the doc. ,, i want only 2 teams on each post ! you mean add repeater for 2 teams and each repeater have the league & the team name ? then how i set the team name list on what the editor was choose ?

    if you please guide me with code example

    #14100
    Anh TranAnh Tran
    Keymaster

    Hi Sadiq,

    Please try to follow these steps:

    1. Create a new custom post type for teams, you can use MB Custom Post Type to do this.
    2. Create a meta box like this:
    add_filter( 'rwmb_meta_boxes', function( $meta_boxes ) {
        $meta_boxes[] = [
            'title' => 'Matches',
            'fields' => [
                [
                    'id' => 'matches',
                    'type' => 'group',
                    'clone' => true,
                    'collapsible' => true,
                    'fields' => [
                        [
                            'id' => 'league',
                            'name' => 'League',
                            'type' => 'text',
                        ],
                        [
                            'id' => 'team1',
                            'name' => 'Team 1',
                            'type' => 'post',
                            'post_type' => 'team',
                        ],
                        [
    
                            'id' => 'team2',
                            'name' => 'Team 2',
                            'type' => 'post',
                            'post_type' => 'team',
                        ],
                    ],
                ],
            ],
        ];
    } );

    PS: Please take the code as a starter point and try to follow the docs for Meta Box and MB Group. As you're the one who knows what you want exactly, you should do the code. I can just only help, but can't do that for you.

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