Posted By

aquelito_ on 10/13/12


Tagged

wordpress wp


Versions (?)

Set Defaut Template if parent page


 / Published in: PHP
 

Parent page with template x Child page auto template x.

You can set a different template.

  1. add_action('save_post','theme_auto_save_parent_page_tpl');
  2. function theme_auto_save_parent_page_tpl(){
  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(empty($_POST['page_template']) && $post->post_parent)
  7. update_post_meta($post->ID,'_wp_page_template', $parent_tmp, $curr_tmp);
  8. }

Report this snippet  

You need to login to post a comment.