Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function add_appcat_automatically($post_ID) {
- global $wpdb;
- $thispost = get_post($post_ID);
- $post_slug = $thispost->post_name;
- if(!wp_is_post_revision($post_ID)) {
- $app_parent = get_option('app_brom');
- $app_name = get_the_title($post_ID);
- $new_term = wp_insert_term( $app_name, 'product_category', $args = array('parent' => $app_parent) );
- if ($new_term instanceof WP_Error) {
- } else {
- $new_term_id = $new_term['term_id'];
- //Everything works till this point and $new_term_id gets correct value
- update_post_meta($post_ID , '_app_cat_id' , 'blue');
- //This does not work. Will change 'blue' to $new_term_id
- }
- }
- }
- add_action('publish_applications', 'add_appcat_automatically');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement