Skip to content
Matth_eu edited this page Sep 24, 2013 · 12 revisions

Post select field. Displays a select input allowing the user to select a post.

Use the 'query' argument to modify the posts that will be available as options. See the documentation on WP Query for more information.

If the 'use_ajax' argument is set to true, the options are populated by an AJAX request when the select field is first clicked.

Post Select Field

Uses Select2, a jQuery based replacement for select boxes.

Args

Required Args

  • id (string) (required)
  • type 'post_select' (required)
  • name (string) Field display name. Used as field label.

Field Specific Args

  • query (array) WP_Query args.
  • use_ajax (bool)
  • allow_none (bool) Add an extra "None" option (only applies when not using the Ajax select)

Optional Generic Args

See Optional Generic Args

Example Usage

array( 
	'id'       => 'example-field-post-select', 
	'name'     => 'Post Select Field', 
	'type'     => 'post_select', 
	'use_ajax' => true,
	'query' => array( 
		'cat' => 8
	)
);