add post meta for custom post type
-
add_action('publish_post', 'add_author_fields'); function add_author_fields($post_ID) { global $wpdb; $user_id = $wpdb->get_var("SELECT post_author FROM $wpdb->posts WHERE ID = $post_ID"); $sitelink = $wpdb->get_var("SELECT meta_value FROM $wpdb->usermeta WHERE meta_key = 'sitename' AND user_id = $user_id"); add_post_meta($post_ID, 'sitename', $sitelink, true); }
This is a working code for the default post type ‘post’. It automatically add a custom field
but it does not work on other custom post typeCan anyone help me
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘add post meta for custom post type’ is closed to new replies.