admin管理员组文章数量:1327959
I am new to PHP. Please help me to achieve the below scenario. I am trying to achieve this from the last 3 days.
I've two categories in my WordPress dashboard named "Available (id:3)" and "Booked (id:4)". In the "available" category a few numbers are there as posts.
In each post page contact 7 form is embedded.
When I submit a "contact form 7" successfully from that post, I would like to move that current post to the "booked" category.
Please check the link and click any numbers for what I am looking for.
'Available' category: / 'Booked' category:/
I tried something like below in my functions.php and not working at all.
add_action('wpcf7_mail_sent', function ($cf7) {
$category_id = get_cat_ID('available');
$post_id = get_the_ID();
wp_remove_object_terms( $post_id, 'available', 'category');
wp_set_object_terms( $post_id, 'booked', 'category');
});
本文标签: categoriesHow to change current category to another in wordpress
版权声明:本文标题:categories - How to change current category to another in wordpress 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742222381a2435525.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论