Thanks for an interesting adaptation of the list-table-extranav-example
example plugin and for your question. Your additional taxonomy filter should be of interest to other MLA users as well.
The original example you started from added an “Author” dropdown control. The “Author” filter already existed as a standard MLA filter (click on an author name in the table column), so the logic had to distinguish between the existing filter and the new dropdown control. Your adaptation is adding an entirely new filter, so the logic is somewhat different.
Briefly, your filter isn’t working because there’s no code to use the selected value to add a taxonomy query to the filters for the submenu table.
I made two changes to your plugin. First, I made a change towards the bottom of the
function to properly display the “No Places” (value ‘-1’) option. Look for:
if ( isset( $_REQUEST['place'] ) && $_REQUEST['place'] > '0' ) {
and change it to:
if ( isset( $_REQUEST['place'] ) && $_REQUEST['place'] !== '0' ) {
Second, I replaced the entire mla_list_table_query_final_terms
function with a new version that handles the taxonomy query addition. Here’s the complete source code for the new function:
/**
* Add 'place' taxonomy query to the query parameters
*
* @since 1.01
*
* @param array $query_terms Current query parameters.
*/
public static function mla_list_table_query_final_terms( $query_terms ) {
if ( isset( $_REQUEST['place'] ) ) {
// Ignore "All Places"
if ( 0 == $place = intval( $_REQUEST['place'] ) ) {
return $query_terms;
}
$tax_filter = 'place';
if ( -1 == $place ) {
$term_list = get_terms( $tax_filter, array(
'fields' => 'ids',
'hide_empty' => false
) );
$place_query = array(
array(
'taxonomy' => $tax_filter,
'field' => 'id',
'terms' => $term_list,
'operator' => 'NOT IN'
)
);
} else {
$place_query = array(
array(
'taxonomy' => $tax_filter,
'field' => 'id',
'terms' => array( $place ),
'include_children' => false,
)
);
}
if ( isset( $query_terms['tax_query'] ) ) {
$query_terms['tax_query']['relation'] = 'AND';
} else {
$query_terms['tax_query'] = array();
}
$query_terms['tax_query'][] = $place_query;
} // isset place
return $query_terms;
} // mla_list_table_query_final_terms
I hope you can incorporate those changes in your plugin and get something that works for your application. I am marking this topic resolved, but please update it if you have problems or further questions regarding the suggested solution. Thanks for a great example of extending the Media/Assistant navigation options.