function wpcustom_load_widget() { register_widget( 'wpcustom_widget' ); } add_action( 'widgets_init', 'wpcustom_load_widget' ); class wpcustom_widget extends WP_Widget { function __construct(){ parent::__construct( 'wpcustom_widget', __('カスタムウィジェット', 'wpcustom_widget_domain'), array( 'description' => __( '', 'wpcustom_widget_domain' ), ) ); } public function widget( $args, $instance ) { $title = apply_filters( 'widget_title', $instance['title'] ); echo $args['before_widget']; if ( ! empty( $title ) ){ echo $args['before_title'] . $title . $args['after_title']; } //増やした設定項目を取得してそのまま出力します $showcount = $instance['showcount']; echo $showcount; echo $args['after_widget']; } public function form( $instance ) { if ( isset( $instance[ 'title' ] ) ) { $title = $instance[ 'title' ]; } else { $title = __( 'タイトルを入力してください', 'wpcustom_widget_domain' ); } //下3行追加しました if ( isset( $instance[ 'showcount' ] ) ) { $showcount = $instance[ 'showcount' ]; } else { $showcount = __( '5', 'wpcustom_widget_domain' );//初期値を設定します } ?>