pifa

Dynamically assign same page template to child page as paren

Jan 13th, 2014
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.35 KB | None | 0 0
  1. add_action('save_post','changeTemplateOnSave');
  2. function changeTemplateOnSave(){
  3. global $post;
  4. $curr_tmp = get_post_meta($post->ID, '_wp_page_template', true);
  5. $parent_tmp = get_post_meta($post->post_parent, '_wp_page_template', true);
  6. if($post->post_parent)
  7. update_post_meta($post->ID,'_wp_page_template',$parent_tmp,$curr_tmp);
  8. }
Advertisement
Add Comment
Please, Sign In to add comment