houzez-preview

Hello everyone,
Today I am going to share my experience while adding metabox on child theme using metabox.io on Houzez child Theme
Houzez Theme use metabox.io plugin to create metabox field on custom post type property as well default WordPress Post type. While using “”rwmb_meta_boxes” filter hook on child theme I came to lost all the metafield created by Houzez Parent Theme. So I start to dig on the code and found that houzez theme provides “houzez_theme_meta” to extend metabox field. You can see this filed on this template:

houzez -> frameworkd -> metabox -> houzez-meta-boxes.php.


So I use “houzez_theme_meta” filter to add metabox on houzez child theme. This is how I add metabox.

add_filter( ‘houzez_theme_meta’, ‘houzez_child_development_metabox’ );
function houzez_child_development_metabox( $meta_boxes ) {
$db_prefix = ‘development_database_’;
$meta_boxes_child[] = array(
‘id’ => ‘development_database’,
‘title’ => esc_html__(‘Development Database Property’, ‘houzez-child’),
‘pages’ => array(‘developments’),
‘tabs’ => array(
‘development_database_property’ => array(
‘label’ => esc_html__(‘Basic Information’, ‘houzez-child’),
‘icon’ => ‘dashicons dashicons-building’,
)
),
‘tab_style’ => ‘left’,
‘fields’ => array(

array(
‘id’ => “{$db_prefix}variable_pricing_min”,
‘name’ => esc_html__(‘Minimum Price’, ‘houzez-child’),
‘desc’ => esc_html__(‘Eg: $3000’, ‘houzez-child’),
‘type’ => ‘text’,
‘std’ => “”,
‘columns’ => 6,
‘tab’ => ‘development_database_property’,
)

)
);
//return $meta_boxes_child;
return array_merge( $meta_boxes, $meta_boxes_child );

}

Note: As $meta_boxes contains scalar value so we are using arary_merge() function here. While using this please uuse seperate prefix for child theme. As I am using ‘development_database_’ to stop conflict in-between parent and chid theme metabox id.

Let me know if you have any question or queries regarding to this, I would be more pleased to answer your question.

Thanks

Advertisements