douzhannao5357 2014-08-23 10:03
浏览 38
已采纳

ACF前端形式wordpress类别不起作用

I am using a acf frontend form to create posts. All the fields are working but on frontend I want a field that should automatically asiign category at backend to the post.

I have custom post type name "person".

For adding the post from frontend form, here is the code

    // Create a new post
$post = array(
    'post_status'  => 'draft' ,
    'post_title'  => $_POST['fields']['field_53c8f0941cec0'] ,
    'post_category'  =>  array(43,47) ,
    'post_type'  => 'person' ,
    'submit_value'  => 'Submit' ,
);  

// insert the post
$post_id = wp_insert_post( $post ); 

. The custom taxonomy name for my "person" custom post type is "person_type" All the fields get saved but category does not gets saved at backend.

ANy help is really appreciated.

  • 写回答

2条回答 默认 最新

  • dongxi1680 2014-08-23 10:15
    关注

    This should be pretty straight Use

    'tax_input'      => array( 'CUSTOM_TAXONOMY_NAME' => array( COMMA SEPARTED VALUES OF TERMS)),
    

    Example

      $post = array(
            'post_status'  => 'Pending' ,
            'post_title'  => $new_title ,
            'post_type'  => 'products' ,
            'tax_input'      => array( 'products_type' => array( 11,33)),
            'post_content' => $contentBlock,
            'submit_value'  => 'Submit' ,
        );  
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥15 c++头文件不能识别CDialog