Skip Navigation

[Resolved] Removed custom field data in frontend

This thread is resolved. Here is a description of the problem and solution.

Problem:

The user had a custom field group called 'cf' with a number custom field called 'count'. They had two custom post types called 'saas' and 'saas1', both with posts containing data in the 'count' custom field. After removing the 'cf' custom field group from 'saas1', the user still saw the 'count' value displayed on the frontend. They wanted to stop displaying the 'count' value without deleting it.

Solution:

Create a separate Elementor layout for 'saas' and 'saas1'. In the layout for 'saas', don't use the 'cf' custom field group. Continue to use 'cf' in the 'saas1' Elementor layout. This way, the 'count' values won't be displayed for the 'saas' post type while still being available for the 'saas1' post type.

This support ticket is created 2 years, 1 month ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

This topic contains 2 replies, has 2 voices.

Last updated by fahimS-2 2 years, 1 month ago.

Assisted by: Christopher Amirian.

Author
Posts
#2570183

Tell us what you are trying to do?
I have a custom field group called cf and in that group there is a number custom field called count. I have two custom post types called saas and saas1. I have some posts in both saas and saas1. And the posts have data in the custom field count. I created a elementor template to display saas and saas1. In that template, I displayed the value of count with the help of elementor.

Now from the backend, I removed cf from saas1. Now custom field group cf doesn't belong to saas1. But when I am visiting the posts of saas1 in the frontend, the value of count is visible.
You can check it here: hidden link

I don't want to delete the values of count in saas1. How can I stop displaying them?

#2571441

Christopher Amirian
Supporter

Languages: English (English )

Hi there,

The easiest way is to copy your layout in Elementor and have a separate layout for saas, there do not use the cf in the layout at all.

Keep using cf in the saas1 Elementor layout.

The only other way is to delete the cf values in saas post type.

You either can do it manually or perform the database SQL code below:

DELETE FROM wp_postmeta WHERE meta_key = 'wpcf-cf' AND post_id IN (SELECT ID FROM wp_posts WHERE post_type = 'saas');

This query will delete all rows from the wp_postmeta table where the meta_key is wpcf-cf and the post_id is in the result set of a subquery that selects all post IDs from the wp_posts table where the post_type is saas.

After running this query, the values of the wpcf-cf custom field will be deleted for all posts of the saas post type. However, the values for saas1 post type will remain intact.

Note: Replace wp_ with your WordPress database table prefix if it's different from the default value. Also, it's always a good idea to test this query on a staging site before running it on a live site.

Warning:Do not use the SQL code above unless you have complete backup of your website as I did not test the code so I am not sure if it will work 100% on your site. The code is what I gathered from the information you gave me.

Thanks.

#2571739

My issue is resolved now. Thank you!