Need a conditional to test if title of parent page matches title of child page
-
In my main loop, I need a conditional to test if title of parent page matches title of child page. Default might be to keep h1 tag , otherwise do not display.
Here’s the code without conditional. :
<!-- basic loop --> <?php if (have_posts()) : while (have_posts()) : the_post() ; ?> <h2> <?php $parent_title = get_the_title($post->post_parent); echo $parent_title; ?> </h2> <h1 style="margin-bottom:12px"><?php the_title(); ?></h1> <?php the_content(); ?> <?php endwhile; endif; ?>
ex) I want h1 to show here… https://howlingwolfmedia.com/site3/my-club/facilities/
but not here: https://howlingwolfmedia.com/site3/my-club/
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Need a conditional to test if title of parent page matches title of child page’ is closed to new replies.