meta box attribute to use with gallery

Support General meta box attribute to use with gallery

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #38611
    Mark McLachlanMark McLachlan
    Participant

    The dev who built this gallery provides the following to output ACF custom fields to define the content of the galleries.
    The plugin extends the normal WordPress gallery.

    What should I use as an attribute ($atts) to do this with Metabox custom fields?

    add_filter( 'shortcode_atts_gallery', function( $result, $defaults, $atts ) {
      if ( !empty( $atts['acf'] ) ) {
        $gallery_id_array = get_field( $atts['acf'], get_the_ID() );
        $ids = implode( ',', $gallery_id_array );
        $result['ids'] = $ids;
      }
      return $result;
    }, 10, 3 );
    #38612
    Long NguyenLong Nguyen
    Moderator

    Hi,

    It's just an attribute of the Meow gallery shortcode, you can change it to anything that you want. For example

    add_filter( 'shortcode_atts_gallery', function( $result, $defaults, $atts ) {
      if ( !empty( $atts['my_meta_box'] ) ) {
        ...
      }
      return $result;
    }, 10, 3 );

    shortcode: [meow-gallery my_meta_box="my_meta_box_gallery_field"]

    But I'm not sure if this plugin can work with Meta Box. You should contact the plugin support to ask for more information.

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