I am trying to:
function insert_dia_cerrado( $concesionario_id, $fecha ) {
// if "Post" exists
if($concesionario_id) {
$ppp_post = array(
'post_title' => $fecha,
'post_status' => 'publish',
'post_author' => 1,
'post_type' => 'cerrado'
);
$ppp_post_id = wp_insert_post( $ppp_post );
if($ppp_post_id) {
update_post_meta( $ppp_post_id, 'wpcf-dia-cerrado', $fecha);
toolset_connect_posts( 'cerrado', $concesionario_id, $ppp_post_id );
}
}
}
I got this code from: https://toolset.com/forums/topic/how-to-add-repeatable-field-values-via-code/
But when I call the function (just once), like:
insert_dia_cerrado (15, '29-05-2020');
The field is inserted, but twice (you can see attached image)
how could i prevent this?
I was thinking using post_exists but it could exists for other post.. so..
any thoughts?
Hello and thank you for contacting the Toolset support.
To better help with this issue, and to isolate it from any possible conflicts with your theme/plugins/server setup, I created a test server on our platform. Please log into it, add your code, and reproduce the issue. If it is reproduced, I'll look into it. If it is not reproduced, check on your test site if this issue appears when:
- Only Toolset plugins are activated. It will tell us if there is an interaction issue with another plugin.
- The theme is set to a WordPress default like Twenty Fourteen. It will tell us if there is an interaction issue with your theme.
If the problem disappears, start activating one at the time to track where the incompatibility is produced.
Please check the login information in my previous private message(May 14, 2020 at 3:21 pm)