Add meta value to custom post type on publish
You are usgin an undefined $post->ID variable because there is no reference to any $post object in your code; instead, use the $post_ID variable retrieved in the function: function on_jobs_publish( $post_ID ) { global $wpdb; $wpdb->insert( ‘iCrewzWp_postmeta’, array( ‘post_id’ => $post_ID, ‘meta_key’ => ‘_yoast_wpseo_sitemap-include’, ‘meta_value’ => ‘always’ ), array( ‘%d’, ‘%s’, ‘%s’ ) ); } … Read more