Upgrade Existing Code for Filter in List?
You’ve helped me with the following code (below). It no longer works to re-map the display (ie: lookup the ID’s in each row of the Session List, and instead, display the speaker name). Any ideas on how to fix this?
/**
* @param array $args
* @param AC\Column $column
*
* @return array
*/
function wwdvc_filter_format_unserialize_options( $args, AC\Column $column ) {
if( $column instanceof AC\Column\CustomField && ‘session_speakers_list’ === $column->get_meta_key()
){
# grab all speaker IDs for faster processing
$speaker_posts = get_posts(array(
‘numberposts’ => -1, // get all posts.
‘post_type’ => ‘speaker’,
‘post_status’ => ‘any’,
));
$speaker_lookup = wp_list_pluck( $speaker_posts, ‘post_title’, ‘ID’ );
foreach ( $args[‘options’] as $value => $label ) {
$speakers = unserialize( $value );
$match = array();
foreach($speakers as $idx) {
array_push($match, $speaker_lookup[$idx]);
}
$args[‘options’][ $value ] = implode(‘,’,$match);
}
}
return $args;
}
add_filter( ‘acp/filtering/dropdown_args’, ‘wwdvc_filter_format_unserialize_options’, 10, 2 );
You must be logged in to reply to this topic.