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( … Read more

How to call multiple functions from multiple files into a WordPress page template [closed]

Just add your functions to your theme’s functions.php file. They will be available to all of the templates within the theme. functions.php: function add_cars_specifications() { if ( in_category( ‘cars’ ) ) { echo types_render_field( ‘cars-specs’, array() ); } } In your page template file and other templates in the theme, add_cars_specifications() will be in scope, … Read more