Advertisement
adeens

update_post_meta

Jul 18th, 2011
412
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.71 KB | None | 0 0
  1. function add_appcat_automatically($post_ID) {
  2. global $wpdb;
  3. $thispost = get_post($post_ID);
  4. $post_slug = $thispost->post_name;
  5.  
  6. if(!wp_is_post_revision($post_ID)) {
  7. $app_parent = get_option('app_brom');
  8. $app_name = get_the_title($post_ID);
  9. $new_term = wp_insert_term( $app_name, 'product_category', $args = array('parent' => $app_parent) );
  10.  
  11. if ($new_term instanceof WP_Error) {
  12. } else {
  13. $new_term_id = $new_term['term_id'];
  14. //Everything works till this point and $new_term_id gets correct value
  15.  
  16. update_post_meta($post_ID , '_app_cat_id' , 'blue');
  17. //This does not work. Will change 'blue' to $new_term_id
  18. }
  19. }
  20. }
  21. add_action('publish_applications', 'add_appcat_automatically');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement