Snippet: Adding a First & Last Name Field for Staff Members
By default the theme uses the title for the names of your staff members. However, if you need to sort your staff members by last name or if you want to do custom queries based on first or last names then you may want to add additional fields for this.
add_filter( 'wpex_metabox_array', function( $array ) {
if ( isset( $array['staff'] ) ) {
// Add First name.
$array['staff']['settings']['first_name'] = array(
'title' => __( 'First Name', 'total' ),
'description' => __( 'Field description', 'total' ),
'id' => 'wpex_first_name', // Custom field ID
'type' => 'text',
);
// Add Last name.
$array['staff']['settings']['last_name'] = array(
'title' => __( 'Last Name', 'total' ),
'description' => __( 'Field description', 'total' ),
'id' => 'wpex_last_name', // Custom field ID
'type' => 'text',
);
}
return $array;
} );
All PHP snippets should be added via child theme's functions.php file or via a plugin.
We recommend Code Snippets (100% Free) or WPCode (sponsored)
We recommend Code Snippets (100% Free) or WPCode (sponsored)