Advertisement
Guest User

Untitled

a guest
Apr 28th, 2015
212
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.86 KB | None | 0 0
  1. <?php
  2. add_filter('rwmb_meta_boxes', function ($meta_boxes) {
  3.  
  4. $meta_boxes[] = array(
  5. 'id' => 'gallery',
  6. 'title' => 'Galer&iacute;a',
  7. 'pages' => array('page'),
  8. 'context' => 'normal',
  9. 'priority' => 'high',
  10. 'fields' => array(
  11. array(
  12. 'id' => 'post_gallery',
  13. 'type' => 'file_advanced',
  14. // 'max_file_uploads' => 1,
  15. ),
  16. )
  17. );
  18. return $meta_boxes;
  19. });
  20.  
  21. /**
  22. *
  23. * @param int $post_id
  24. * @return string|bool
  25. */
  26. function get_gallery_shortcode($post_id = 0) {
  27. $gallery_ids = get_gallery_ids($post_id = 0);
  28. return !empty($gallery_ids) ? sprintf('[gallery ids="%s"]', implode(',', $gallery_ids)) : FALSE;
  29. }
  30.  
  31. /**
  32. *
  33. * @param type $post_id
  34. * @return type
  35. */
  36. function get_gallery_ids($post_id = 0) {
  37. $post_id = (is_numeric($post_id) && 0 < $post_id) ? (int) $post_id : get_the_ID();
  38. return get_post_meta(get_the_ID(),'post_gallery');
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement