Custom Post Conditional for Parent & Child Single.php?

Following on from previous question but needs to be more specific so thought a new topic would be best…

Conditional tag for custom post parent and children on their corresponding single.php, currently i have the following..

Read More
    <?php if ( is_home() || is_page( 'overview' ) || is_page( 'about' )  ) : ?>
        Home Page
    <?php elseif ( 'artists' == get_post_type() ): ?>
        artist parent               
    <?php elseif ( $post->post_parent > 0 ): ?> 
     artist   child
    <?php else : ?>
     empty other pages etc

   <?php endif; ?>

The issue being the parent shows up on all the single-artists.php pages.

I need to specifically target the parent single and the child single, is it possible as i don’t think it is…?

Thank you.

Related posts

1 comment

  1. I guess that you should change the order to first check if there is any parent:

    <?php if ( is_home() || is_page( 'overview' ) || is_page( 'about' )  ) : ?>
        Home Page
    <?php elseif ( $post->post_parent > 0 ): ?> 
     artist   child
    <?php elseif ( 'artists' == get_post_type() ): ?>
        artist parent               
    <?php else : ?>
     empty other pages etc
    

Comments are closed.