Support » Plugin: Toolset Types - Custom Post Types, Custom Fields and Taxonomies » How to set a parent post of Custom post type from theme?

  • Hi all,

    I have 2 custom post type, “Tables” and “ponens”, I configured with Types plugin, and I set the parent of “Ponens” with “Tables”.

    I try to make a little script that insert a post from one formulary of theme of wordpress, when the user send the form, I insert a new post of “Ponens”, the problem that I have is, when I make the insert with “wp_insert_post();” I need to set the parent of that post, for exmple here is my code:

    $post = array(
    ‘post_title’ => $titulo,
    ‘post_content’ => $resumen_ponencia,
    ‘post_status’ => ‘pending’, //Set the status of the new post.
    ‘post_type’ => ‘ponencias’, //You may want to insert a regular post, page, link, a menu item or some custom post type
    ‘post_parent’=> $list_mesas

    $postId = wp_insert_post( $post );

    The insert is not the problem, the problem is that when I go to the admin of wordpress and I go to the new post that was insert, the parent is not set. The combo of list of tables appear in blank.

    Someone know how make this?.


  • The topic ‘How to set a parent post of Custom post type from theme?’ is closed to new replies.