WP_Widget_Pages::form()publicWP 2.8.0

Outputs the settings form for the Pages widget.

Method of the class: WP_Widget_Pages{}

No Hooks.

Return

null. Nothing (null).

Usage

$WP_Widget_Pages = new WP_Widget_Pages();
$WP_Widget_Pages->form( $instance );
$instance(array) (required)
Current settings.

Changelog

Since 2.8.0 Introduced.

WP_Widget_Pages::form() code WP 6.5.2

<?php
public function form( $instance ) {
	// Defaults.
	$instance = wp_parse_args(
		(array) $instance,
		array(
			'sortby'  => 'post_title',
			'title'   => '',
			'exclude' => '',
		)
	);
	?>
	<p>
		<label for="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>"><?php _e( 'Title:' ); ?></label>
		<input class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'title' ) ); ?>" type="text" value="<?php echo esc_attr( $instance['title'] ); ?>" />
	</p>

	<p>
		<label for="<?php echo esc_attr( $this->get_field_id( 'sortby' ) ); ?>"><?php _e( 'Sort by:' ); ?></label>
		<select name="<?php echo esc_attr( $this->get_field_name( 'sortby' ) ); ?>" id="<?php echo esc_attr( $this->get_field_id( 'sortby' ) ); ?>" class="widefat">
			<option value="post_title"<?php selected( $instance['sortby'], 'post_title' ); ?>><?php _e( 'Page title' ); ?></option>
			<option value="menu_order"<?php selected( $instance['sortby'], 'menu_order' ); ?>><?php _e( 'Page order' ); ?></option>
			<option value="ID"<?php selected( $instance['sortby'], 'ID' ); ?>><?php _e( 'Page ID' ); ?></option>
		</select>
	</p>

	<p>
		<label for="<?php echo esc_attr( $this->get_field_id( 'exclude' ) ); ?>"><?php _e( 'Exclude:' ); ?></label>
		<input type="text" value="<?php echo esc_attr( $instance['exclude'] ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'exclude' ) ); ?>" id="<?php echo esc_attr( $this->get_field_id( 'exclude' ) ); ?>" class="widefat" />
		<br />
		<small><?php _e( 'Page IDs, separated by commas.' ); ?></small>
	</p>
	<?php
}