konweb
5/14/2019 - 7:00 AM

Change template file to be Include

Change template file to be Include

<?php
/**
 * Change template file to be Include
 */
function mytheme_template_include( $template ) {
  global $post;

  $recruit_post = get_page_by_path('recruit');

  if ( $post->post_parent === $recruit_post->ID ) {
    $job_template = locate_template( ['page-job.php'] );
    if ( $job_template ) {
      return $job_template ;
    }
  }

  return $template;
}
add_filter( 'template_include', 'mytheme_template_include', 99 );