0

Check on the single-artists.php whether we are viewing the parent or child of the said custom post?

Tried this but always shows the top child content, rather then showing the two different area

<?php if ('artists' == get_post_type()  || $post->post_parent=='artists') { ?>

           the child single-artists.php

<?php } else { ?>

           the parent single-artists.php


<?php } ?>

1 Answer 1

0

post_parent is a numerical value field in $post object. So you should check if there's a valid number. Try this -

<?php if ( $post->post_parent > 0 ) { ?>
    the child single-artists.php
<?php } else { ?>
    the parent single-artists.php
<?php } ?>
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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