Hi,
Thank you for contacting us and I'd be happy to assist.
It is possible to restore the Toolset custom field, that has been removed from the field group. Please go to WP Admin -> Toolset -> Custom Fields and you'll see a button for "Post Field Control".
Clicking it will take you to the "Post Field Control" section which will show the fields which have been removed from the custom field group. The "Change assignment" link below the field can be used to put it back into the field group.
( screenshot: lien caché )
If you'd still prefer to use the same "book-summary" slug as the WYSIWYG field while maintaining the existing custom multiline field data, you can follow these steps:
Important note: Make a full backup copy of the website first and make sure to follow the steps in the order mentioned.
1. Add a new WYSIWYG field in the same field group, with a slug "book-summary-temp".
2. To copy the custom field values from the field "book-summary" to this new custom field, you'll need a custom shortcode:
add_shortcode('custom_copy_custom_fields', 'custom_copy_custom_fields_func');
function custom_copy_custom_fields_func( $atts ) {
$a = shortcode_atts( array(
'type' => '',
'from' => '',
'to' => ''
), $atts );
// get all the target posts
$args = array(
'post_type' => $a['type'],
'posts_per_page' => -1,
'post_status' => 'any',
);
$posts = get_posts( $args );
foreach ($posts as $post) {
$from_value = types_render_field( $a['from'], array( 'item' => $post->ID, 'output' => 'raw', 'suppress_filters' => true ) );
if(!empty($from_value)) {
update_post_meta( $post->ID, 'wpcf-'.$a['to'], $from_value );
}
}
}
The above code snippet can be included through either Toolset's custom code feature ( ref: https://toolset.com/documentation/adding-custom-code/using-toolset-to-add-custom-code/ ) or through the active theme's "functions.php" file.
3. Add a new temporary page and include this new shortcode, so that 'type' attribute has the target post type slug, 'from' attribute has 'copy from' field slug, and 'to' attribute has 'copy to' field slug:
[custom_copy_custom_fields type="book" from="book-summary" to="book-summary-temp"]
Visit this temporary page after saving and this shortcode will cycle through all posts in the "book" post type and copy field data from the "book-summary" field to the "book-summary-temp" field.
4. Check the edit screen of a few book posts and once confirmed that the field data has been copied, remove the custom shortcode from the page and save it.
5. Remove the "book-summary" field from the field group and then delete it from the "Post Field Control" section.
6. Visit the field group again and add a new WYSIWYG field with the same slug "book-summary". It will not show so the warning message this time.
7. To copy the field data from the "book-summary-temp" field back to the "book-summary" field, you can use the custom shortcode again on the temporary page, but, this time switching the 'from' and 'to' attributes:
[custom_copy_custom_fields type="book" from="book-summary-temp" to="book-summary"]
8. Once confirmed that the field data has been copied to the new WYSIWYG field, you can delete the temporary page with the shortcode and remove the "book-summary-temp" field from the field group and the "Post Field Control" section.
I hope this helps and please let me know if you need any further assistance around this.
regards,
Waqar