Skip to content
mattheu edited this page Apr 28, 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

  • id (string) (required)
  • type 'post_select' (required)
  • name (string) Field display name. Used as field label.
  • desc (string) Field description. Displayed below label.
  • query (array) WP_Query args.
  • use_ajax (bool)
  • repeatable (bool)
  • cols (int) [1-12]

Example Usage

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