admin管理员组文章数量:1410731
I have two Custom Post Types called book
and publisher
. The book
has two Custom Fields (Metabox) author_fname
and author_lname
and the publisher
has a Custom Taxonomy called authors
Now can you please let me know how I can use book
metaboxes (author_fname
and author_lname
) to dynamically create a taxonomy ( authors
) term for publisher
as soon as the new Custom Post of book
is published?
Here is the code I have
function add_cpt_term($post_ID) {
$post = get_post($post_ID);
$meta = get_post_custom($post);
$mfname = $meta['author_fname'][0];
$mlname = $meta['author_lname'][0];
if (!term_exists($mfname. " " . $mlname, 'authors'))
wp_insert_term( $mfname. " " . $mlname, 'authors', array('slug' => $mfname. " " . $mlname));
}
add_action('publish_book', 'add_cpt_term');
Not Getting any error but it is not publishing any term either
本文标签: Issue on Creating Custom Tax Term Dynamically From Another CPT Metabox On Publish
版权声明:本文标题:Issue on Creating Custom Tax Term Dynamically From Another CPT Meta-box On Publish 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744923489a2632445.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论