Support

Account

Home Forums Front-end Issues Relationship – splitting results by post type Reply To: Relationship – splitting results by post type

  • I’ve done this with get_post_type():

    <?php
    
    $rel_field_ids = get_field( 'rel_field' );
    $rel_field_ids_grouped = array();
    
    foreach ( $rel_field_ids as $rel_field_id )
    {
    	$post_type = get_post_type( $rel_field_id );
    	$rel_field_ids_grouped[ $post_type ][] = $rel_field_id;
    }
    
    ksort( $rel_field_ids_grouped );
    print_r( $rel_field_ids_grouped );
    
    ?>

    Code not tested.