Adding/Removing Fields & Tabs In Theme Settings Metabox
If you are looking to add new fields to your site please use the newer WPEX_Meta_Factory class or the ACF plugin
You may have noticed that the Total theme includes a Theme Settings Metabox that displays below your posts and pages and allows you to modify things on a per-page basis. This functionality can be disabled completely via the Theme Panel and can also be customized via a child theme. The Snippet below shows how you can use the "wpex_metabox_array" filter to hook into the settings to add or remove options and tabs.
/**
* Modify the Theme Settings metabox.
*
* Available "types" : text, date, number, text_html, link, textarea, code, checkbox, select,
* color, media, editor
*
* @link https://total.wpexplorer.com/docs/snippets/adding-fields-page-settings/
*/
add_filter( 'wpex_metabox_array', function( $array ) {
// Add new textfield to "media" tab which is used for blog posts by default.
$array['media']['settings']['my_new_field'] = array(
'title' => __( 'My Title', 'total' ), // Custom field title
'description' => __( 'My Description', 'total' ), // Custom field description
'id' => 'my_custom_field_id', // Custom field ID used to retrive via get_post_meta
'type' => 'text', // Type to display in the admin
);
// Remove the "Redirect" setting from the "Main" tab.
unset( $array['main']['settings']['post_link'] );
// Create your own tab - cool!
$array['my_new_tab'] = array(
'title' => __( 'My Tab', 'wpex' ), // Tab title
'post_type' => array( 'post' ), // Used to limit by post type, to display on all don't add this param
'settings' => array(
'my_new_field' => array(
'title' => __( 'My Title', 'total' ), // Custom field title
'description' => __( 'My Description', 'total' ), // Custom field description
'id' => 'my_custom_field_id', // Custom field ID used to retrive via get_post_meta
'type' => 'text', // Type to display in the admin
),
),
);
return $array;
}, 40 );
All PHP snippets should be added via child theme's functions.php file or via a plugin (we recommend Code Snippets)