create a wp gallery

Support General create a wp gallery

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #7964
    brkardbrkard
    Participant

    Hi.

    I want to create native wp gallery under posts with advanced image field.

    I can do this with Acf Pro with the code below.

    $image_ids = get_field('gallery', false, false);
    $shortcode = '[' . 'gallery ids="' . implode(',', $image_ids) . '"]';
    
    echo do_shortcode( $shortcode );

    Can i do this with metabox advanced image field with a code ? If i can i will be very happy if you share a snippet code for this.

    Thanks.

    #7990
    Truong GiangTruong Giang
    Participant

    Hi there,

    Please replace $image_ids = get_field('gallery', false, false); with this:

    $image_ids = rwmb_meta( 'gallery' );

    Thank you.

    #8129
    brkardbrkard
    Participant

    Hi i cant make this work.

    I only need to generate a native wp gallery shortcode with images that i add with metabox advanced image field.

    Can you check and share a code snippet if it is poosible and not too complicated for you.

    Sorry to take your time 🙁

    Thanks.

    #8153
    Anh TranAnh Tran
    Keymaster

    Hi,

    Can you try this code:

    $images = rwmb_meta( 'gallery' );
    $image_ids = array_keys( $images );
    $shortcode = '[' . 'gallery ids="' . implode(',', $image_ids) . '"]';
    
    echo do_shortcode( $shortcode );
    #8154
    brkardbrkard
    Participant

    Hi Anh.

    Works perfectly.

    Thank you very much.

    #8216
    Anh TranAnh Tran
    Keymaster

    PS: This question is transformed to a tutorial. Thanks @brkard for a great question.

Viewing 6 posts - 1 through 6 (of 6 total)
  • The topic ‘create a wp gallery’ is closed to new replies.