build custom meta boxes for soccer matches
Support › MB Conditional Logic › build custom meta boxes for soccer matches
- This topic has 3 replies, 2 voices, and was last updated 6 years ago by
Anh Tran.
-
AuthorPosts
-
April 8, 2019 at 6:17 AM #14088
sadiq ahmed
Participanthello
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 ... etcApril 8, 2019 at 2:38 PM #14091Anh Tran
KeymasterHi 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.
April 8, 2019 at 4:40 PM #14094sadiq ahmed
Participanthi
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
April 9, 2019 at 4:10 PM #14100Anh Tran
KeymasterHi Sadiq,
Please try to follow these steps:
- Create a new custom post type for teams, you can use MB Custom Post Type to do this.
- 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.
-
AuthorPosts
- You must be logged in to reply to this topic.