Skip to content

Instantly share code, notes, and snippets.

@firefly05
Last active March 25, 2021 02:15
Show Gist options
  • Save firefly05/6262b4e5f2cc6a0968248c20781787c5 to your computer and use it in GitHub Desktop.
Save firefly05/6262b4e5f2cc6a0968248c20781787c5 to your computer and use it in GitHub Desktop.
/**
* 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