Execute Closing Shortcode After the_content


I need to execute a short code on thousands of posts which don’t already contain the short code as i’ve added some manually.

I’m using another function to add the opening short code after the 2nd paragraph which works.

I’ve written this code which outputs the closing short code after the content but it does’t execute.

add_filter( 'the_content', 'closing_shortcode' );
function closing_shortcode( $content ) {

        if( !has_shortcode( $content, 'members') )
        return $content;

        $close_shortcode = do_shortcode('[/member]');

        return $content . $close_shortcode;

Maybe i need to use echo do_shortcode.

, Brad Dalton 3 years 2020-06-08T08:10:21-05:00 0 Answers 86 views 0

Leave an answer