Created
October 17, 2025 10:35
-
-
Save blogjunkie/8e590af66532a14a3fe090ca44122f8b to your computer and use it in GitHub Desktop.
Bulletproof check for page built with Elementor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php // Don't copy this line | |
| $post_id = get_queried_object_id(); | |
| $is_elementor = false; | |
| if ( function_exists('did_action') && did_action('elementor/loaded') ) { // Check if Elementor is loaded | |
| $is_elementor = \Elementor\Plugin::instance()->db->is_built_with_elementor( $post_id ); | |
| } else { | |
| // Fallback when Elementor isn't loaded: check post meta flag | |
| $is_elementor = get_post_meta( $post_id, '_elementor_edit_mode', true ) === 'builder'; | |
| } | |
| if ( $is_elementor ) { | |
| // Page is built with Elementor | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment