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


If you know the solution of this issue, please leave us a reply in Comment section, to update the question.

Wordpress related questions and answers: