Last active
March 25, 2021 02:15
-
-
Save firefly05/6262b4e5f2cc6a0968248c20781787c5 to your computer and use it in GitHub Desktop.
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
/** | |
* Post IDs expects an array of values, or an array with a single value. | |
* Removing the '_elementor_edit_mode' turns elementor off. All the elementor settings | |
* are still saved in meta and will reapply if "Edit with elementor" is clicked again. | |
* | |
* The elementor content is stored in the _elementor_data post meta | |
*/ | |
function kanopi_convert_elementor_to_classic_block( $post_ids ){ | |
foreach ($post_ids as $post_id) { | |
// turn off elementor. | |
delete_post_meta( $post_id, '_elementor_edit_mode' ); | |
// wrap the content in one div. | |
$content = '<div class="zen-elementor-removed">'; | |
$content .= get_the_content( null, false, $post_id ); | |
$content .= '</div>'; | |
// update the content in the post. | |
$post_settings = array( | |
'ID' => $post_id, | |
'post_content' => $content, | |
); | |
wp_update_post( $post_settings ); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment