Created
December 5, 2017 10:04
-
-
Save morgyface/8eca7ad083d3db270caf0e2a4936cfa8 to your computer and use it in GitHub Desktop.
WordPress | If parent uses specific template
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?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