Whilst I’m still look for a better option, this is my solution thus far.
Around line 516 in slt_cf_init.php I replaced…
$current_category = array();
foreach ( $posts as $post_data ) {
if ( $field[ 'group_options' ] ) {
$this_category = get_the_category( $post_data->ID );
if ( empty( $current_category ) || $this_category[0]->cat_ID != $current_category[0]->cat_ID ) {
// New category, initiate an option group
$field['options'][ $this_category[0]->cat_name ] = '[optgroup]';
$current_category = $this_category;
}
}
…with…
$current_post_type = array();
foreach ( $posts as $post_data ) {
if ( $field[ 'group_options' ] ) {
$this_post_type = get_post_type( $post_data->ID );
$this_post_type = get_post_type_object( $this_post_type );
if ( empty( $current_post_type ) || !in_array( $this_post_type->name, $current_post_type ) ) {
// New category, initiate an option group
$field['options'][ $this_post_type->name ] = '[optgroup]';
array_push( $current_post_type, $this_post_type->name );
}
}
Which essentially switch the grouping from categories (which I’m not using) to post types.
The next problem was that the posts don’t come out in post-type order, rather they are mixed up. And there is no out of the box orderby parameter for post-type so I’ve resorted to creating a hidden meta field that stores the post-type name for each post – thus I can use the meta_value and orderby value options that are available.
It works a treat really, and seeing Steve’s notes in vicinity suggesting that this grouping feature might get expanded beyond category makes me think it’ll do for now.
But as before andy views would be most welcome, this stuff doesn’t come naturally to me.