Enables you to modify the array of available book fields. Here’s an example of how you could use this filter to add your own custom field:
/** * Add the "Cover Artist" field to the available book layout options. * * @param array $fields * * @return array */ function novelist_cover_artist_field( $fields ) { $fields['cover_artist'] = array( 'name' => __( 'Cover Artist', 'novelist-cover-artist' ), 'placeholder' => '[cover_artist]', 'label' => sprintf( __( '<strong>Cover Artist:</strong> %s', 'novelist-cover-artist' ), '[cover_artist]' ), 'linebreak' => 'on' ); return $fields; } add_filter( 'novelist/book/available-fields', 'novelist_cover_artist_field' );
There are four fields to be filled out in the array:
- name – Name of your field. Only used in the admin area.
- placeholder – Code you want to use as a placeholder in the template. This doesn’t need to be a real shortcode – just a snippet of text we’ll replace later.
- label – Default template.
- linebreak – Whether or not the “Add line break after this field” option should be checked off or on.