Support Forum
I'm doing something a little out of the ordinary. I'm using the MB Term Meta to create a list of items that I want to use later on in the admin. Basically, if a WP category is selected, I want to show some additional meta associated with the category and use that meta to change the template on the front end. To do this, I made a custom metabox which grabs the data out of the category I'm using.
Here's the code for the custom metabox, it's pretty straight-forward. The problem is, I don't think it's even firing on the latest version of WP. I can't even get it to echo anything out. There were some changes to meta fields in the newest version and I haven't had a chance to dig in. For now, I'm rolling back my install, but any help would be very much appreciated!
if ( class_exists( 'RWMB_Field' ) ) {
class RWMB_Unit_Field extends RWMB_Checkbox_List_Field {
public static function filter_options( $field, $options ) {
$current_categories = get_the_category();
foreach( $current_categories as $cat ){
$units = rwmb_meta( 'unit', array( 'object_type' => 'term' ), $cat->term_id );
}
$options = [];
foreach ( $units as $unit ){
$options[] = (object) array( 'value' => sanitize_title_with_dashes($unit['name']), 'label' => $unit['name'] );
}
return $options;
}
}
}