Add container div to gallery using post_gallery

I am trying to add a container div to the WordPress gallery, I have this so far….

function gallery_custom( $output ) {

    $return = '<div class="mydiv">';
    $return = $output;
    $return = '</div>';

    return $return;
}

add_filter( 'post_gallery', 'gallery_custom', 10, 3 );

This is not returning anything, any ideas where I am going wrong?

Read more here: Add container div to gallery using post_gallery

Leave a Reply

Your email address will not be published. Required fields are marked *