Created
November 19, 2015 14:57
-
-
Save ewistrand/6d207d9f221dcf07def3 to your computer and use it in GitHub Desktop.
WP Add default custom fields to posts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Add Default Custom Fields To Posts | |
* Note: This is just an example. | |
*/ | |
add_action('wp_insert_post', 'set_default_custom_fields'); | |
function set_default_custom_fields($post_id){ | |
// slides can be post or any custom post type | |
if ( $_GET['post_type'] == 'slides' ) { | |
add_post_meta($post_id, 'subtitle', '', true); | |
add_post_meta($post_id, 'description', '', true); | |
add_post_meta($post_id,'link_url','',TRUE); | |
add_post_meta($post_id,'link_label','',TRUE); | |
} | |
return true; | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment