Last active
October 23, 2023 14:22
-
-
Save prosvitco/bb3ca4d48a15ce5544729a173af67f75 to your computer and use it in GitHub Desktop.
Parent Page and Sub Pages Conditional Content Display
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
| global $post; | |
| if (is_page()) { | |
| if ($post->post_parent) { | |
| echo '<h1>Child page: ' . $post->post_title . '</h1>'; | |
| echo '<p>You can display content specific to child pages here.</p>'; | |
| } else { | |
| echo '<h1>Page parent: ' . $post->post_title . '</h1>'; | |
| echo '<p>You can display content specific to parent pages here.</p>'; | |
| } | |
| } else { | |
| echo '<p>You can handle other content types or scenarios here.</p>'; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment