Actually, I tested now and realized that though I can pick a category, that category is not being saved. I bet I did something pretty wrong, sorry to botter again. This is what I did:
// Custom query for grid pages
function bento_grid_query() {
$post_id = get_queried_object_id();
$bento_grid_query_args = array();
$post_types = get_post_meta( $post_id, 'bento_page_content_types', true );
$bento_grid_query_args['post_type'] = $post_types;
$bento_grid_query_args['post_tag'] = $post_tag;
$bento_grid_query_args['category'] = $category;
if ( is_front_page() ) {
$bento_paged = ( get_query_var('page') ) ? get_query_var('page') : 1;
} else {
$bento_paged = ( get_query_var('paged') ) ? get_query_var('paged') : 1;
}
$bento_grid_query_args['paged'] = $bento_paged;
$bento_grid_number_items = get_post_meta( $post_id, 'bento_page_number_items', true );
if ( ctype_digit($bento_grid_number_items) && ctype_digit($bento_grid_number_items) != 0 ) {
$bento_grid_query_args['posts_per_page'] = (int)$bento_grid_number_items;
} else {
$bento_grid_query_args['posts_per_page'] = get_option('posts_per_page');
}
return $bento_grid_query_args;
}
// Page settings metaboxes
function bento_metaboxes() {
// Define strings
$bento_prefix = 'bento_';
$bento_ep_url = wp_kses(
'<a href="https://satoristudio.net/bento-free-wordpress-theme/#expansion-pack/?utm_source=disabled&utm_medium=theme&utm_campaign=theme" target="_blank">Expansion Pack</a>',
array(
'a' => array(
'href' => array(),
'target' => array(),
),
)
);
// Callback to display a field only on single post types
function bento_show_field_on_single() {
$current_screen = get_current_screen();
if ( $current_screen->id == 'page' ) {
return false;
} else {
return true;
}
}
// Function to add a multicheck with post types
add_action( 'cmb2_render_multicheck_category', 'bento_render_multicheck_category', 10, 5 );
function bento_render_multicheck_category( $args = '', $post_category, $category ) {
$defaults = array(
'show_option_all' => '',
'show_option_none' => '',
'orderby' => 'id',
'order' => 'ASC',
'show_count' => 0,
'hide_empty' => 1,
'child_of' => 0,
'exclude' => '',
'echo' => 1,
'selected' => 0,
'hierarchical' => 0,
'name' => 'cat',
'id' => '',
'class' => 'postform',
'depth' => 0,
'tab_index' => 0,
'taxonomy' => 'category',
'hide_if_empty' => false,
'option_none_value' => -1,
'value_field' => 'term_id',
'required' => false,
);
wp_dropdown_categories( 'show_count=1&hierarchical=1' );
/**
* Filters the taxonomy drop-down output.
*
* @since 2.1.0
*
* @param string $output HTML output.
* @param array $r Arguments used to build the drop-down.
*/
}