Descripción
// Deletes first gallery shortcode and returns content function strip_shortcode_gallery( $content ) { preg_match_all( '/'. get_shortcode_regex() .'/s', $content, $matches, PREG_SET_ORDER ); if ( ! empty( $matches ) ) { foreach ( $matches as $shortcode ) { if ( 'gallery' === $shortcode[2] ) { $pos = strpos( $content, $shortcode[0] ); if ($pos !== false) return substr_replace( $content, '', $pos, strlen($shortcode[0]) ); } } } return $content; } // Example of how to use: $content = strip_shortcode_gallery( get_the_content() ); // Delete first gallery shortcode from post content $content = str_replace( ']]>', ']]>', apply_filters( 'the_content', $content ) ); // Apply filter to achieve the same output that the_content() returns echo $content; ?>