jmccole83
12/12/2017 - 5:38 PM

Display Siblings of a CPT

Copy to you themes template, update the name of the CPT as required.

<?php
  global $post;
  if ( isset ($post) ){
      $post_parent = $post->ID;
      if ( !empty($post->post_parent) ){
          $post_parent = $post->post_parent;
      }   
          $args = array( 'posts_per_page' => -1, 'post_parent' => $post->post_parent, 'post_type'=> 'custom-post-name' );
          $myposts = get_posts( $args );
          foreach ( $myposts as $post ) : setup_postdata( $post ); ?>
              // html content
          <?php endforeach;
          wp_reset_postdata();
  
      }
?>