I created a CPT called [grundeinstellung] where I store data that repeats across the entire website, such as phone numbers, social media, etc. Then, I created a custom field group that represents the necessary fields in the CPT. I was able to create an article, enter the data there, and retrieve it by ID from that article.
Now, I would like to store multiple articles with various settings in this CPT. Meaning: ID:1 outputs field group 1, ID:2 outputs field group 5, etc. Unfortunately, in the conditional settings, there is no option to target a specific article. Is there a code or workaround for this, or do I need to create a separate CPT for each such settings page?
I tried to replicate the code with the following function but sadly it isn't working. Also I haven't found the slug of a fieldgroup so i added the ID.
function func_remove_field_groups_for_grundeinstellung() {
global $post_type;
global $post;
if ($post_type == 'grundeinstellung' && isset($post->ID)) {
if ($post->ID == 21) {
$meta_boxes = [
'wpcf-group-cpt-78'
];
foreach ($meta_boxes as $meta_box) {
if ($meta_box != 'wpcf-group-cpt-20') {
remove_meta_box($meta_box, $post_type, 'normal');
}
}
}
}
}
add_action('admin_head', 'func_remove_field_groups_for_grundeinstellung');
Can you please share problem URL and tell me on what post ID you want to display what custom field group and what custom field group should not be not display.
*** Please make a FULL BACKUP of your database and website.***
I would also eventually need to request temporary access (WP-Admin and FTP) to your site. Preferably to a test site where the problem has been replicated if possible in order to be of better help and check if some configurations might need to be changed.
I have set the next reply to private which means only you and I have access to it.
I see you added the following to the custom field group's "Data-Dependent" tab that is available when you click on "Edit" button on your custom field group screen:
=> hidden link
($(form_data['id']) eq 21)
I've removed the above code you added and I can see it working as expected.