Hi @philipp_halla,
You can achieve that something like these
global $no_preview_for_this_shortcode = false;
add_action('cs_before_preview_frame', 'no_preview_for_this_shortcode', -9999);
function no_preview_for_this_shortcode () {
global $no_preview_for_this_shortcode;
$no_preview_for_this_shortcode = true;
}
//Your shortcode here
add_shortcode('this_is_my_shortcode', 'this_is_my_shortcode');
function this_is_my_shortcode () {
global $no_preview_for_this_shortcode;
if( $no_preview_for_this_shortcode ) return false; //Simply exit the function, no rendering.
//And do your shortcode's internal here
}
This is just an idea and not a complete solution, you’re free to enhance it but we couldn’t provide custom development related to this. Another solution would be changing your !is_admin() condition similar to this
if ( ! isset( $_POST['cs_preview_state'] ) || ! $_POST['cs_preview_state'] || 'off' === $_POST['cs_preview_state'] ) {
//do your shortcode's internal here
}
Admin or logged in, it may not work within the preview since it’s mixed. The only way to make it happen is by checking if it’s a preview request from the builder.
Thanks!