novelist/book/available-fields

⌘K
  1. Home
  2. Developers
  3. Filters
  4. novelist/book/available-fields

novelist/book/available-fields

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:

  1. name – Name of your field. Only used in the admin area.
  2. 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.
  3. label – Default template.
  4. linebreak – Whether or not the “Add line break after this field” option should be checked off or on.
Was this article helpful to you? No Yes

How can we help?