__( 'Latest News Widget ', 'spasalon'), ) // Args
);
}
public function widget( $args , $instance ) {
$instance['news_cat'] = (isset($instance['news_cat'])?$instance['news_cat']:'');
$instance['exclude_post_id'] = isset($instance['exclude_post_id']) ? $instance['exclude_post_id'] : '';
$instance['news_column'] = isset($instance['news_column']) && $instance['news_column']!='' ? $instance['news_column'] : 2;
$excludepost_id = explode(',',$instance['exclude_post_id']);
$news_layout = 12 / $instance['news_column'];
$i = 1;
$args = array( 'post_type' => 'post','ignore_sticky_posts' => 1 , 'cat' => $instance['news_cat'] , 'post__not_in' => $excludepost_id );
$post_type_data = new WP_Query( $args );
echo '
';
if( $post_type_data->have_posts() ):
while( $post_type_data ->have_posts() ): $post_type_data ->the_post();
?>
';
$i=0;
}
$i++;
endwhile;
endif;
echo '';
}
public function form( $instance ) {
$instance['news_cat'] = isset($instance['news_cat']) ? $instance['news_cat'] : '';
$instance['exclude_post_id'] = isset($instance['exclude_post_id']) ? $instance['exclude_post_id'] : '';
$instance['news_column'] = isset($instance['news_column']) ? $instance['news_column'] : 2;
?>