Advertisement
Guest User

Untitled

a guest
Dec 18th, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.42 KB | None | 0 0
  1. function jjm_add_custom_box(){
  2. add_meta_box(
  3. 'jjm_concert_box_id', // Unique ID
  4. 'concert toevoegen', // Box title
  5. 'jjm_custom_box_concert_html', // Content callback, must be of type callable
  6. 'concert' // Post type
  7. );
  8. add_meta_box(
  9. 'jjm_artiest_box_id', // Unique ID
  10. 'Voeg een nieuwe artiest toe', // Box title
  11. 'jjm_custom_box_artiest_html', // Content callback, must be of type callable
  12. 'artiest' // Post type
  13. );
  14. add_meta_box(
  15. 'jjm_zaal_box_id', // Unique ID
  16. 'zaal toevoegen', // Box title
  17. 'jjm_custom_box_zaal_html', // Content callback, must be of type callable
  18. 'zaal' // Post type
  19. );
  20. add_meta_box(
  21. 'jjm_concert_zaal_box_id', // Unique ID
  22. 'Koppel zaal', // Box title
  23. 'jjm_custom_box_concert_zaal_html', // Content callback, must be of type callable
  24. 'concerts' // Post type
  25. );
  26. }
  27. function jjm_custom_box_concert_zaal_html($post){
  28. $value_gekoppelde_zaal_id = get_post_meta($post->ID,'_concert_zaal', true);
  29. print("<h1>Koppel concert met zaal</h1>");
  30.  
  31. $zalen = get_all_of_post_type('zaal');
  32.  
  33. foreach($zalen as $zaal){
  34. print("<input type='radio' name='concert_zaal' value='" . $zaal->ID . "' " .
  35. ($zaal->ID == $value_gekoppelde_zaal_id ? "checked": "") . ">". $zaal->post_title ."</input>");
  36. }
  37. }
  38. function get_all_of_post_type( $type_name = '') {
  39. $items = array();
  40. if ( !empty( $type_name ) ) {
  41. $args = array(
  42. 'post_type' => "{$type_name}",
  43. 'posts_per_page' => -1,
  44. 'order' => 'ASC',
  45. 'orderby' => 'title'
  46. );
  47. $results = get_posts( $args );
  48. }
  49. return $results;
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement