daily pastebin goal
61%
SHARE
TWEET

Untitled

a guest Feb 18th, 2019 72 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. add_action('save_post', set_post_meta_field_value, 10,3);
  2.  
  3.  
  4. function set_post_meta_field_value( $post_id, $post, $update ) {
  5.  
  6.     // only want to set if new post
  7.     if ( $update ) {
  8.         return;
  9.     }
  10.     // only set for post_type = puppy
  11.     if ( 'post' !== $post->get_post_type() ) {
  12.         return;
  13.     }
  14.  
  15.     // set listing-post-id meta field to the $post_id
  16.     $post_id = get_post();
  17.     add_post_meta($post_id, 'listing-post-id', $post_id);
  18. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top