So I want to apply two separate templates, to two different types of pages (not posts). Both page types are children pages.
The template 'exhibition-template.php' is applied to all pages that are children of the 'archive' page. This works! I do this with a function in functions.php that tests to see if a page is a child of 'archive', then use that function in page.php to apply the template:
//////////////////////////////////////////////
function is_archivechild() {
// Set up the objects needed
$my_wp_query = new WP_Query();
$all_wp_pages = $my_wp_query->query(array('post_type' => 'page', 'posts_per_page' => '-1'));
// Get the page as an Object
$archive = get_page_by_title('archive');
// Filter through all pages and find archive's children
$archive_children = get_page_children( $archive->ID, $all_wp_pages );
if ($archive_children > 0){
return true;
}
else{
return false;
}
}
//////////////////////////////////////////////
And using it in page.php:
//////////////////////////////////////////////
elseif ( is_archivechild() ) {/*a function made up in functions.php, tests if it is a of archive*/
get_template_part( 'exhibition-template' );
get_template_part( 'normalfooter' );
}
//////////////////////////////////////////////
The problem is when I write the function a second time with new variables, and try to implement it in the exact same way except for applying 'artist-template.php' to children pages of 'artists', nothing changes, in fact it still applies 'exhibition-template.php' no matter what.
//////////////////////////////////////////////
function is_artistschild() {
// Set up the objects needed
$artist_query = new WP_Query();
$all_wp_pages = $artist_query->query(array('post_type' => 'page', 'posts_per_page' => '-1'));
// Get the page as an Object
$artists = get_page_by_title('artists');
// Filter through all pages and find artists's children
$artists_children = get_page_children( $artists->ID, $all_wp_pages );
if ($artists_children > 0){
return true;
}
else{
return false;
}
}
//////////////////////////////////////////////
elseif ( is_artistchild() ) {/*a function made up in functions.php, tests if it is a CHILD page, aka an exhibition*/
get_template_part( 'artist-template' );
get_template_part( 'normalfooter' );
}
//////////////////////////////////////////////
Whaaaaat the hell is going on?!?!? much thanks!