1

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..

    <?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.

0

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.