Putting a wordpress custom post into a widget

You will need a “form” and an “update” method for your widget class.

  function form($instance) {
    $instance = wp_parse_args(
      (array) $instance,
      array ('show')
    );
    $show = (!empty($instance['show'])) ? $instance['show'] : '';
    echo '<input type="text" name="'.$this->get_field_name('show').'" value="'.esc_attr($show).'" />';
  }

  function update($new_instance, $old_instance) {
    $instance = $old_instance;
    $instance['show'] = ($new_instance['show']) ? $new_instance['show'] : 1;
    return $instance;
  }

The “form” method creates the back-end form. The “update” method updates the database. Most of the work is handled by the parent widget class.

Then use your ‘show’ variable– $instance['show'] to query for a post. I’ve included a default post to load.

function widget($args, $instance) { // widget sidebar output
    extract($args, EXTR_SKIP);
    echo $before_widget; // pre-widget code from theme
    $pid = (!empty($instance['show'])) ? $instance['show'] : 123; // 123 is a default
    $p = get_post($pid);
    // echo your formatted post however you want
    echo $after_widget; // post-widget code from theme
}

http://codex.wordpress.org/Function_Reference/get_post