Adding post from frontend with related fields
-
Hello,
i’m stuck and i need your help, please.
I have this scenario:
– Advanced Content Type called “ciudades”. Inside, 2 fields: “ciudad” and “provincia”.
– Custom Post Type called “anuncios”. There are some fields, but i’ll focus on two fields: “provincia” and “ciudad” (related to the pod “ciudades” and its fields)
– I have a custom form to add a new post into “anuncios” passing data through $_POST. There are some text fields in it, a simple select field (for “provincia”‘s items) and a checkbox field (for “ciudad”‘s items).The post is created and text areas are added successfully but nothing works with select field and checkbox although their values are being passed right through $_POST because i can do an echo of them.
This is the code i’m using to add the fields into the new post:
$fields= array(
‘post_title’ => $nombre,
‘post_content’ => $contenido,
‘post_author’ => $autor,
‘provincia.provincia’ => $provincia,
‘ciudad.ciudad’ => $ciudad
);$new_id = $anuncios->add($fields);
What code should i use to achieve that?
Thank you very much!
- The topic ‘Adding post from frontend with related fields’ is closed to new replies.