Automatically use specific template to load subpages

Before getting the top level parent page, you could check if the page has parents; also you forget to define $template.

This code should work:

function load_usetemplate( $template ){

    global $post;

    if( $post->post_parent > 0 ) {

      // get top level parent page
      $parent = get_post( reset( array_reverse( get_post_ancestors( $post->ID ) ) ) );

      if( $parent->ID === pll__(8) ){
        if ( $child_template = locate_template( 'page-joinery-subpages.php') ) 
            return $child_template;
      }

    }

    return $template;
}
add_filter( 'page_template', 'load_usetemplate' );

deneme bonusu veren sitelerbahis casinomakrobetceltabetpinbahispolobetpolobet girişpinbahis girişmakrobet girişpulibet girişmobilbahis girişkolaybet giriş