Automatic category conflict problems
-
Hi all,
Hope this the right place for this question.
I’m making a site for a journalist to showcase her work. It will feature online examples of her work,and print examples.
I’ve made two plugins which I’ve placed in the mu-plugins folder. Their purpose is to make two new custom post types. One is called “online” and the other “print”. The plugins also automatically assign a category of the same name to each of the post types. So, “online” are automatically marked as “online” and “print” is marked with the “print” category.
However, there seems to be some sort of conflict, as if I run both plugins, all posts, regardless of the custom post type being used, revert to being put in the “online” category. If I remove the “online” custom post plugin, things revert to “print” as I would want so I’m assuming there is a conflict.
Here’s my code for the “online” post type’s auto-category part at the bottom of the file….
// Automatically assign online category. // (Only if no other category has been manually specified) function add_ion_online_post_category_automatically($post_ID) { global $wpdb; if(!has_term('','category',$post_ID)){ $iononlinepostcat = online; wp_set_object_terms($post_ID, $iononlinepostcat, 'category'); } } // Save online post add_action('save_post', 'add_ion_online_post_category_automatically'); add_action('save_post', 'ion_save_online_posts_meta', 1, 2);And here’s the code for my “print” auto category/saving…
// Automatically assign print category. // (Only if no other category has been manually specified) function add_ion_print_post_category_automatically($post_ID) { global $wpdb; if(!has_term('','category',$post_ID)){ $ionprintpostcat = "print"; wp_set_object_terms($post_ID, $ionprintpostcat, 'category'); } } // Save print post add_action('save_post', 'add_ion_print_post_category_automatically'); add_action('save_post', 'ion_save_print_posts_meta', 1, 2);Any help or ideas as to what’s going wrong would be appreciated! I can provide more code if required.
The topic ‘Automatic category conflict problems’ is closed to new replies.