Getting the title of the parent page and displaying it only for certain parent pages

Question

I’d need to fetch the title of a parent page on a page that shows a catalog of several pages, like this:

enter image description here

I know how to do displaying the parent page:

<p><strong><?php echo get_the_title( $post->post_parent ); ?></strong></p>

But I’m wondering how to make this happen only with certain parent pages, where showing the parent page title makes it more clear what the child page is about. For others, I wouldn’t want to show it. I hope this makes sense.

I believe I should probably use <?php if (is_page() ) : ?> <?php endif; ?> somehow and wrap that around the whole thing, but I’m unsure about how to fit the syntax together since I’m not super familiar with php at this point. Can someone help me out?

0
M.K. 2 months 0 Answers 8 views 0

Leave an answer