【问题标题】:Wordpress: add custom taxonomy to a page programmaticallyWordpress:以编程方式将自定义分类添加到页面
【发布时间】:2011-05-03 00:56:58
【问题描述】:

您好,我正在尝试通过表单向页面添加自定义分类术语(分层)。我对每个条款都有一个复选框:

<input type="checkbox" name="term1" value="$taxonomy_term_id"/> 
<label for="themes" > $term_name </label>

<input type="checkbox" name="term2" value="$taxonomy_term_id2"/> 
<label for="themes" > $term_name2 </label>
[...]

提交时我正在使用 wp_set_object_terms 函数:

wp_set_object_terms($page_id,$_POST['term1'],$taxonomy_name,false);

但它只创建一个名称为 $_POST['term1'] 值的分类术语(在管理面板中,页面没有检查新分类术语,即使已创建新术语)。

有什么想法吗?

【问题讨论】:

    标签: wordpress taxonomy


    【解决方案1】:

    就是这样:

       $wpdb->insert( $wpdb->prefix .'term_relationships', array('object_id'=>$post_id, 'term_taxonomy_id'=>$_POST['term'], 'term_order'=>'0'));
    

    【讨论】:

      猜你喜欢
      • 2017-07-29
      • 1970-01-01
      • 1970-01-01
      • 2010-09-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多