Forums

If Parent Show… ElseIf Child Show… On same single page? (1 post)

  1. jezthompson
    Member
    Posted 3 months ago #

    I have a custom post type of 'editors' which is working fine.

    Each post type will have various child posts of the main editor parent.

    On the single-editors.php page i need it to show x content if its the PARENT, but if its the CHILD show completely different content and ignore any parent content obviously...

    Is it possible... have the following so far..

    <?php get_header(); ?>
    <!-- IF Parent Show Below -->
    <?php $this_page_id=$wp_query->post->ID; ?>
    <?php query_posts(array('showposts' => 1, 'post_parent' => $this_page_id, 'post_type' => 'editors')); while (have_posts()) { the_post(); ?>
    <h2><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h2>
    <?php } ?>
    <!-- IF Child Show Below ignore the above -->
    <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
    <section role="document">
    <?php the_content(); ?>
    </section>
    <?php endwhile; endif; ?>
    <?php get_footer(); ?>

Reply

You must log in to post.

About this Topic