How to Add a Custom Field Tab

Editus allows you to add a custom tab to the post settings dialog to edit custom meta fields from the frontend. This can be useful with Advanced Custom Fields plugin or other plugins that rely on custom meta fields. Let’s say you have a custom field called “Custom Field1” and you want add it to Editus’s dialog box. Here is the end result. You can simply edit and hit “Save.”

customtab

To achieve this, you need to add a little bit of PHP codes. Your custom PHP codes can be inserted into your theme’s functions.php file. Or more preferably, you can inject the following codes using a custom php plugin.

You need to implement an Editus filter called ‘lasso_modal_tabs’ Here is the full example codes to recreate the above example. You can add multiple fields or tabs.

use lasso_public_facing\register_meta_field;

new register_meta_field(array('custom_field1'=> 'trim'));

add_filter('lasso_modal_tabs','custom_tabs',10,1);
function custom_tabs( $tabs ){

    $tabs[] = array(
        'name' => 'New Tab',
	'options'	=> 'myOptionsCallback'
    );

    return $tabs;
}

function myOptionsCallback(){

	$options = array(
		array(
			'id'		=> 'custom_field1',
			'name' 		=> 'Custom Field1',
			'type'		=> 'text',
			'default'	=> 'default',
			'desc'		=> 'Custom Field1'
		)
	);

	return $options;
}