最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

Best action hook to create custom post and assign taxonomy terms to it on plugin activation?

programmeradmin1浏览0评论

When I install the plugin, I want to create 10 CPTs of a particular type, which I define in the init action hook, and want to assign 10 terms of a custom taxonomy, which too is defined in an init callback. I tried doing it on register_activation_hook, but the CPT's terms are not set. Is there a way to achieve this?

When I install the plugin, I want to create 10 CPTs of a particular type, which I define in the init action hook, and want to assign 10 terms of a custom taxonomy, which too is defined in an init callback. I tried doing it on register_activation_hook, but the CPT's terms are not set. Is there a way to achieve this?

Share Improve this question asked Aug 7, 2015 at 9:11 Rutwick GangurdeRutwick Gangurde 8,6245 gold badges43 silver badges55 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 0

According to the docs, I needed to set the terms using post ID. So after every insert, I used the ID to set the terms https://codex.wordpress/Function_Reference/wp_set_post_terms

Someone might find this useful.

发布评论

评论列表(0)

  1. 暂无评论