Wordpress:以编程方式将自定义分类添加到页面
您好,我正在尝试通过表单将自定义分类术语(分层)添加到页面。我为每个术语都有一个复选框:
<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'] 的值(在管理面板中,该页面没有检查新的分类术语,甚至创建了新术语 )。
有什么想法吗?
Hi i'm attempting to add custom taxonomy terms (hierarchical) to a page, via a form. I have a checkbox for each terms:
<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>
[...]
On submit i'm using wp_set_object_terms function:
wp_set_object_terms($page_id,$_POST['term1'],$taxonomy_name,false);
but it only create a taxanomy term whose name is the value of $_POST['term1'] ( in admin panel, the page as no new taxonomy term checked, even the new term created ).
Any idea?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
就是这样:
This is it: