• Resolved DenisCGN

    (@deniscgn)


    Hello,
    I try to customize the WP GALLERY shortcode.
    I created my own shortcode to customize the gallery.

    function kik_author_gallery_id(){
    $the_images = get_post_meta( '181', 'kik_gallery' );
    $the_images = implode( ',',$the_images );
    return '[gallery columns="4" ids="'.$the_images.'" link="file"]';
    }
    add_shortcode( 'kik_author_gallery', 'kik_author_gallery_id' );

    Now, when I put the shortcode [kik_author_gallery] into the post body it only shows this

    [gallery columns="4" ids="184,185,186,187,197,198,367,368,369,370" link="file"]

    Not the gallery itself.

    Why?

    Can someone help?

    Cheers,
    Denis

Viewing 2 replies - 1 through 2 (of 2 total)
  • Moderator bcworkz

    (@bcworkz)

    Shortcodes are not recursive. A shortcode within a shortcode expansion will not also be expanded, you have to explicitly expand it. To do so, try this:
    return do_shortcode('[gallery columns="4" ids="'.$the_images.'" link="file"]');

    Thread Starter DenisCGN

    (@deniscgn)

    Hey bcworkz,

    thanks so much, this does the trick!

    Cheers,
    Denis

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Shortcode GALLERY’ is closed to new replies.