Content in Fields Delete on Publish (REST API ISSUE)
-
I am currently struggling with the REST API ‘true’ setting causing the content in certain custom fields to delete after publish.
When I turn the setting ‘false’ the custom fields associated with that post type save correctly as they should. When made “true’, the fields delete on publish.
I have tested all the other settings I could within the Custom Fields and CPT UI plugins and could not find anything else that is causing the issue.
I would like to have the new block editor because it formats content more seamlessly, but cannot have these fields delete. Any help on this would be greatly appreciated!
PHP: 7.4.33
WP: 6.1
CPT UI: 1.13.1
Custom Fields: 6.0.4
-
can you share your post type settings via CPTUI Menu > Tools and the blob of content on the right, for the post type tab? I don’t have any idea why this is happening, since we don’t have any active hand in publishing content, but I want to see if I could maybe recreate in some way.
Sure Thing!:
{"planning-board":{"name":"planning-board","label":"Planning Boards ","singular_label":"Planning Board","description":"This is a custom post type for Planning Board meetings and Minutes. ","public":"true","publicly_queryable":"true","show_ui":"true","show_in_nav_menus":"true","delete_with_user":"false","show_in_rest":"false","rest_base":"","rest_controller_class":"","rest_namespace":"","has_archive":"false","has_archive_string":"","exclude_from_search":"false","capability_type":"post","hierarchical":"true","can_export":"false","rewrite":"true","rewrite_slug":"","rewrite_withfront":"true","query_var":"true","query_var_slug":"","menu_position":"","show_in_menu":"true","show_in_menu_string":"","menu_icon":"dashicons-excerpt-view","register_meta_box_cb":null,"supports":["title","editor","custom-fields","revisions"],"taxonomies":["meetings_minutes"],"labels":{"menu_name":"Planning Board","all_items":"All Agendas and Minutes","add_new":"Add New Document","new_item":"New Document","add_new_item":"","edit_item":"","view_item":"","view_items":"","search_items":"","not_found":"","not_found_in_trash":"","parent_item_colon":"","featured_image":"","set_featured_image":"","remove_featured_image":"","use_featured_image":"","archives":"","insert_into_item":"","uploaded_to_this_item":"","filter_items_list":"","items_list_navigation":"","items_list":"","attributes":"","name_admin_bar":"","item_published":"","item_published_privately":"","item_reverted_to_draft":"","item_scheduled":"","item_updated":""},"custom_supports":"","enter_title_here":""},"town_board":{"name":"town_board","label":"Town Boards","singular_label":"Town Board","description":"Posts pertaining to town board activities","public":"true","publicly_queryable":"true","show_ui":"true","show_in_nav_menus":"true","delete_with_user":"false","show_in_rest":"false","rest_base":"","rest_controller_class":"","rest_namespace":"","has_archive":"false","has_archive_string":"","exclude_from_search":"false","capability_type":"post","hierarchical":"false","can_export":"false","rewrite":"true","rewrite_slug":"","rewrite_withfront":"true","query_var":"true","query_var_slug":"","menu_position":"","show_in_menu":"true","show_in_menu_string":"","menu_icon":"dashicons-excerpt-view","register_meta_box_cb":null,"supports":["title","editor","custom-fields"],"taxonomies":["meetings_minutes"],"labels":{"menu_name":"Town Board","all_items":"All Agendas and Minutes","add_new":"Add New Document","add_new_item":"","edit_item":"","new_item":"","view_item":"","view_items":"","search_items":"","not_found":"","not_found_in_trash":"","parent_item_colon":"","featured_image":"","set_featured_image":"","remove_featured_image":"","use_featured_image":"","archives":"","insert_into_item":"","uploaded_to_this_item":"","filter_items_list":"","items_list_navigation":"","items_list":"","attributes":"","name_admin_bar":"","item_published":"","item_published_privately":"","item_reverted_to_draft":"","item_scheduled":"","item_updated":""},"custom_supports":"","enter_title_here":""},"job_posting":{"name":"job_posting","label":"Job Postings","singular_label":"Job Posting","description":"","public":"true","publicly_queryable":"true","show_ui":"true","show_in_nav_menus":"true","delete_with_user":"false","show_in_rest":"true","rest_base":"","rest_controller_class":"","rest_namespace":"","has_archive":"false","has_archive_string":"","exclude_from_search":"false","capability_type":"post","hierarchical":"true","can_export":"false","rewrite":"true","rewrite_slug":"","rewrite_withfront":"true","query_var":"true","query_var_slug":"","menu_position":"","show_in_menu":"true","show_in_menu_string":"","menu_icon":"","register_meta_box_cb":null,"supports":["title","editor","thumbnail","custom-fields","page-attributes","post-formats"],"taxonomies":["category","meetings_minutes"],"labels":{"menu_name":"","all_items":"","add_new":"","add_new_item":"","edit_item":"","new_item":"","view_item":"","view_items":"","search_items":"","not_found":"","not_found_in_trash":"","parent_item_colon":"","featured_image":"","set_featured_image":"","remove_featured_image":"","use_featured_image":"","archives":"","insert_into_item":"","uploaded_to_this_item":"","filter_items_list":"","items_list_navigation":"","items_list":"","attributes":"","name_admin_bar":"","item_published":"","item_published_privately":"","item_reverted_to_draft":"","item_scheduled":"","item_updated":""},"custom_supports":"","enter_title_here":""},"public_notice":{"name":"public_notice","label":"Public Notices","singular_label":"Public Notice","description":"","public":"true","publicly_queryable":"true","show_ui":"true","show_in_nav_menus":"true","delete_with_user":"false","show_in_rest":"true","rest_base":"","rest_controller_class":"","rest_namespace":"","has_archive":"false","has_archive_string":"","exclude_from_search":"false","capability_type":"post","hierarchical":"true","can_export":"false","rewrite":"true","rewrite_slug":"","rewrite_withfront":"true","query_var":"true","query_var_slug":"","menu_position":"","show_in_menu":"true","show_in_menu_string":"","menu_icon":"","register_meta_box_cb":null,"supports":["title","editor","thumbnail","post-formats"],"taxonomies":["category","post_tag"],"labels":{"menu_name":"","all_items":"","add_new":"","add_new_item":"","edit_item":"","new_item":"","view_item":"","view_items":"","search_items":"","not_found":"","not_found_in_trash":"","parent_item_colon":"","featured_image":"","set_featured_image":"","remove_featured_image":"","use_featured_image":"","archives":"","insert_into_item":"","uploaded_to_this_item":"","filter_items_list":"","items_list_navigation":"","items_list":"","attributes":"","name_admin_bar":"","item_published":"","item_published_privately":"","item_reverted_to_draft":"","item_scheduled":"","item_updated":""},"custom_supports":"","enter_title_here":""}}
We have several Post Types, it seems like all of which are having issues. I can confirm definitely that it happens in both “planning boards” and “town Boards”, haven’t consistently tested it in the other post types. Let me know if you need more from me! Thanks.
Forgot to request this part earlier. Steps to create/recreate would be to set up the post types, set up at least one field with ACF for the post type, and then create a post, save some data to the field, confirm data exists after saving as a draft, and then switch the post status to publish and see if the field data disappears?
Hi Michael,
That is pretty much correct. Generally I go straight to publish, but I have tried the procedure with both ‘save draft’ and ‘publish’. In both attempts, when REST API is ‘true’, the information will not save in the fields ON THE FIRST TRY! It will save after the second try, in most cases. This only becomes apparent, however, when you leave the post and come back in. It will “look” like it has correctly filled the fields, but exiting and coming back in will reveal it has not!
The reason I know this is because those fields will not show on the front end of the website when being pulled dynamically AS SOON AS I leave the post after publishing. Even if I don’t go back in, the information is lost. Therefore it must be happening either at the save point or at the exit point of the post.
I would make a test post with the REST API ‘true’ , do the saving and checking procedures, then trash that post and try another one with the REST API ‘false’. This is how I discovered the issue
Thanks!
Thus far I haven’t been able to recreate. I’ve created a basic textarea field and assigned to display on the
planning boards
post type. I’ve typed in some random characters hit publish, and refreshed and both times (REST true and REST false), the data has persisted without me having to re-save at all.May be worth trying on a staging site where you can disable everything except ACF and CPTUI and see if it still happens there. Added bonus in switching to one of the default themes in case it’s theme code potentially interfering in some way.
Hi Michael,
Thanks for looking into it. I will go back and run some more tests on my end to see if it has to do with any plugins I’m running. Have you heard anything similar to this with anyone else finding solutions? If I find out what it is I will let you know for your documentation.
Thanks!
Just a question, did you have the custom fields REST API on or off in the field group settings?
I never touched any REST API settings for custom fields, as I didn’t know ACF had a setting for that. So that would have been whatever is default.
Gotcha,
I tested that as well and didn’t seem to make any difference. Have a good evening! Get back to you soon.
Thanks,
Hi Michael,
We finally found a solution to the issue. Our specific firewall settings were restricting the use of the REST API and certain functions of the CPT UI & ACF plugins.
Here is the documentation that refers somewhat to the issue we were having. Once we adjusted the firewall settings, including some JSON settings as well, we were no longer having the issue and I was able to keep ‘REST API’ as ‘True’ with no problem! This was the best possible solution as we wanted the new block editor but also wanted to having everything save on the first try haha! So if you wouldn’t mind maybe putting this in your knowledge base for another time this might be brought up? This was extremely confusing and frustrating for us, and I would love to save someone else from having the same issues!
Let me know if you have any more specific questions that might help, I did not make the firewall settings changes but I can get more details from the person who did if you need them!
- The topic ‘Content in Fields Delete on Publish (REST API ISSUE)’ is closed to new replies.