Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function mes_pages_meta_init(){
- $post_id = $_GET['post'] ? $_GET['post'] : $_POST['post_ID'];
- if(get_post_meta($post_id,'_wp_page_template',TRUE) == 'votre-template.php'){
- add_post_meta($post_id, 'custom_field_1', 'valeur-par-defaut', true);
- add_post_meta($post_id, 'custom_field_2', 'valeur-par-defaut', true);
- }
- elseif(get_post_meta($post_id,'_wp_page_template',TRUE) == 'votre-autre-template.php'){
- add_post_meta($post_id, 'custom_field_3', 'valeur-par-defaut', true);
- add_post_meta($post_id, 'custom_field_4', 'valeur-par-defaut', true);
- add_post_meta($post_id, 'custom_field_5', '', true);
- }
- return true;
- }
- add_action('wp_insert_post', 'mes_pages_meta_init');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement