Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- add_filter('rwmb_meta_boxes', function ($meta_boxes) {
- $meta_boxes[] = array(
- 'id' => 'gallery',
- 'title' => 'Galería',
- 'pages' => array('page'),
- 'context' => 'normal',
- 'priority' => 'high',
- 'fields' => array(
- array(
- 'id' => 'post_gallery',
- 'type' => 'file_advanced',
- // 'max_file_uploads' => 1,
- ),
- )
- );
- return $meta_boxes;
- });
- /**
- *
- * @param int $post_id
- * @return string|bool
- */
- function get_gallery_shortcode($post_id = 0) {
- $gallery_ids = get_gallery_ids($post_id = 0);
- return !empty($gallery_ids) ? sprintf('[gallery ids="%s"]', implode(',', $gallery_ids)) : FALSE;
- }
- /**
- *
- * @param type $post_id
- * @return type
- */
- function get_gallery_ids($post_id = 0) {
- $post_id = (is_numeric($post_id) && 0 < $post_id) ? (int) $post_id : get_the_ID();
- return get_post_meta(get_the_ID(),'post_gallery');
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement