I am making a custom Pages screen to display all of my published pages.
I started with Matt Van Andel's excellent Custom List Table Example that works with WP_List_Table
.
Each item looks something like this:
array(
'id' => 1,
'page' => 'page1',
'url' => 'page1'
)
Some of my pages have alternate content stored in postmetas. For the pages that have this, I want them to force a row beneath the main row so let's say page 2 has such data what I want is where the 2 alternate items are grouped with page 2:
id page url alt-id alt-title
1 page1 page1
2 page2 page2
1 alternate-title-1
2 alternate-title-2
3 page3 page3
I can get the $items
array to look like this
array(
'id' => 2,
'page' => 'page2',
'url' => 'page2',
'variations' => array(
array(
alt-id => 2,
alt-title=> 'alternate-title-2',
),
array(
alt-id => 3,
alt-title=> 'alternate-title-3',
)
)
)
How do I force a row like this, so that items with a 'variations' array will display their data below their own row?
Do I need to make my own function that's similar to this? https://developer.wordpress.org/reference/classes/wp_list_table/display/
Maybe I use this to display multiple rows if necessary? https://developer.wordpress.org/reference/classes/wp_list_table/display_rows/
But how can I get my WP_List_Table class to call display_rows_alternate instead?