Reputation: 3520
Is it possible to have a conditional if statement for a specific custom template page in wordpress?
Example:
<?php if ( is_page('custom-home.php') ) { ?>
//do this on my home page
<?php } elseif ('custom-gallery.php') ) { ?>
//do this on my gallery page
<?php } else { ?>
<?php } ?>
Upvotes: 1
Views: 779
Reputation: 6828
is_page_template
returns true when the specified template is being used:
if( is_page_template( 'custom-home.php' ) ) {
// do home stuff
} elseif( is_page_template( 'custom-gallery.php' ) ) {
// do gallery stuff
}
Upvotes: 2