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:
You can’t add new items for relationship fields (yet) within add/save, but you can set IDs for those items.
'post_title' => $nombre,
'post_content' => $contenido,
'post_author' => $autor,
'provincia' => $provincia, // should be an ID, or an array of IDs
'ciudad' => $ciudad // should be an ID, or an array of IDs
$new_id = $anuncios->add($fields);
Viewing 1 replies (of 1 total)
The topic ‘[Resolved] Adding post from frontend with related fields’ is closed to new replies.