Skip to content

Instantly share code, notes, and snippets.

@morgyface
Created December 5, 2017 10:04
Show Gist options
  • Select an option

  • Save morgyface/8eca7ad083d3db270caf0e2a4936cfa8 to your computer and use it in GitHub Desktop.

Select an option

Save morgyface/8eca7ad083d3db270caf0e2a4936cfa8 to your computer and use it in GitHub Desktop.
WordPress | If parent uses specific template
<?php
$current_id = get_the_ID();
$parent_id = wp_get_post_parent_id( $current_id );
$template = get_page_template_slug( $parent_id );
$template_filename = 'template-page.php'; // Change this to the template name
?>
<?php
if ( $template == $template_filename ) {
echo 'Yes, the parent post uses ' . $template_filename;
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment