Support » Plugin: Pods - Custom Content Types and Fields » Adding post from frontend with related fields

  • Resolved dituyi

    (@dituyi)


    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!

    http://wordpress.org/extend/plugins/pods/

Viewing 1 replies (of 1 total)
  • Plugin Author Scott Kingsley Clark

    (@sc0ttkclark)

    You can’t add new items for relationship fields (yet) within add/save, but you can set IDs for those items.

    Try this:

    $fields= array(
        '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 ‘Adding post from frontend with related fields’ is closed to new replies.