I was surprised to learn that when editing a page using Elementor‘s page builder, is_admin()
returns false. The reason for this is that Elementor is loading the page in an <iframe> element as if it were being viewed on the front-end.
Use code like this to detect when posts or pages are being edited in Elementor. Code like this is useful to me because sometimes I add a meta refresh element to automatically start a download, and I don’t want the redirect and download to happen while editing the page.
//don't do anything if we're editing in Elementor
if( \Elementor\Plugin::$instance->editor->is_edit_mode() ) {
return;
}
Here is other code that relies on a URL querystring parameter.
//don't do anything if we're editing post 1112 in Elementor
if( isset( $_GET['elementor-preview'] ) && '1112' == $_GET['elementor-preview'] ) {
return;
}