* */ // Creating the simple_post widget class simple_post_widget extends WP_Widget { function __construct() { parent::__construct( // Base ID of your widget 'simple_post_widget', // Widget name will appear in UI __('Simple Post Widget', 'simple_post_widget_domain'), // Widget description array('description' => __('Simple Post widget ', 'simple_post_widget_domain'),) ); } /** * Front-end display of widget. * * @see WP_Widget::widget() * Creating widget front-end * This is where the action happens * */ public function widget($args, $instance) { $title = apply_filters('widget_title', $instance['title']); $numberOfListings = apply_filters('widget_numberOfListings', $instance['numberOfListings']); $post_type = esc_attr($instance['post_type']); $show_date = esc_attr($instance['show_date']); $show_description = esc_attr($instance['show_description']); $show_thumb = esc_attr($instance['show_thumb']); $col = $show_thumb == 'on' ? 9 : 12; // $maxlines = esc_attr($instance['maxlines']); // before and after widget arguments are defined by themes echo $args['before_widget']; if (!empty($title)) echo $args['before_title'] . $title . $args['after_title']; if (empty($orderby)) $pfunc = 'post_date desc'; $gp_args = array( 'posts_per_page' => $numberOfListings, 'post_type' => $post_type, 'orderby' => 'post_date', 'order' => 'desc', 'post_status' => 'publish', ); // $loop = new WP_Query( $gp_args ); $posts = get_posts($gp_args); //var_dump($posts); foreach ($posts as $post): echo '
/>
/>
/>