__( 'A Featured Post Widget', 'benevolent' ), ) // Args ); } /** * Front-end display of widget. * * @see WP_Widget::widget() * * @param array $benevolent_args Widget arguments. * @param array $benevolent_instance Saved values from database. */ public function widget( $benevolent_args, $benevolent_instance ) { $benevolent_post_id = intval( $benevolent_instance['post_list'] ); $benevolent_read_more = $benevolent_instance['readmore']; $benevolent_excerpt_char = absint( $benevolent_instance['excerpt_char'] ); $benevolent_show_thumb = $benevolent_instance['show_thumbnail']; if( get_post_type( $benevolent_post_id ) == 'post' ){ $benevolent_qry = new WP_Query( "p=$benevolent_post_id" ); }else{ $benevolent_qry = new WP_Query( "page_id=$benevolent_post_id" ); } if( $benevolent_qry->have_posts() ){ echo $benevolent_args['before_widget']; while( $benevolent_qry->have_posts() ){ $benevolent_qry->the_post(); echo $benevolent_args['before_title'] . apply_filters('the_title', get_the_title()) . $benevolent_args['after_title']; ?>
0, 'label' => __('--choose--', 'benevolent'), ); $benevolent_arg = array('posts_per_page' => -1, 'post_type' => array( 'post', 'page' )); $benevolent_posts = get_posts($benevolent_arg); $benevolent_i = 1; foreach( $benevolent_posts as $benevolent_post ){ $benevolent_postlist[$benevolent_post->ID] = array( 'value' => $benevolent_post->ID, 'label' => $benevolent_post->post_title ); $benevolent_i++; } $benevolent_read_more = !empty( $benevolent_instance['readmore'] ) ? $benevolent_instance['readmore'] : __( 'Read More', 'benevolent' ); $benevolent_excerpt_char = !empty( $benevolent_instance['excerpt_char'] ) ? absint($benevolent_instance['excerpt_char']) : 200 ; $benevolent_show_thumbnail = !empty( $benevolent_instance['show_thumbnail'] ) ? $benevolent_instance['show_thumbnail'] : '' ; $benevolent_post_list = !empty( $benevolent_instance['post_list'] ) ? $benevolent_instance['post_list'] : 0 ; ?>

/>