text_fields = array('em-categorised-posts-title', 'em-categorised-posts-subtitle', 'em-number-of-posts'); $this->select_fields = array('em-select-category', 'em-show-excerpt'); $widget_ops = array( 'classname' => 'elegant_magazine_single_col_categorised_posts', 'description' => __('Displays posts from selected category in single column.', 'elegant-magazine'), 'customize_selective_refresh' => true, ); parent::__construct('elegant_magazine_single_col_categorised_posts', __('EM Posts - Single Column ', 'elegant-magazine'), $widget_ops); } /** * Front-end display of widget. * * @see WP_Widget::widget() * * @param array $args Widget arguments. * @param array $instance Saved values from database. */ public function widget($args, $instance) { $instance = parent::em_sanitize_data($instance, $instance); /** This filter is documented in wp-includes/default-widgets.php */ $title = apply_filters('widget_title', $instance['em-categorised-posts-title'], $instance, $this->id_base); $subtitle = isset($instance['em-categorised-posts-subtitle']) ? $instance['em-categorised-posts-subtitle'] : ''; $category = isset($instance['em-select-category']) ? $instance['em-select-category'] : '0'; $show_excerpt = isset($instance['em-show-excerpt']) ? $instance['em-show-excerpt'] : 'true'; $number_of_posts = '5' ; $excerpt_length = '20'; // open the widget container echo $args['before_widget']; ?>

have_posts()) : while ($all_posts->have_posts()) : $all_posts->the_post(); if (has_post_thumbnail()) { $thumb = wp_get_attachment_image_src(get_post_thumbnail_id(get_the_ID()), 'elegant-magazine-medium'); $url = $thumb['0']; $col_class = 'col-five'; } else { $url = ''; $col_class = 'col-ten'; } global $post; ?>
<?php the_title_attribute(); ?>

0) : ?>
form_instance = $instance; $options = array( 'true' => __('Yes', 'elegant-magazine'), 'false' => __('No', 'elegant-magazine') ); //print_pre($terms); $categories = elegant_magazine_get_terms(); if (isset($categories) && !empty($categories)) { // generate the text input for the title of the widget. Note that the first parameter matches text_fields array entry echo parent::em_generate_text_input('em-categorised-posts-title', 'Title', 'Single Column Posts'); echo parent::em_generate_text_input('em-categorised-posts-subtitle', 'Subtitle', 'Single Column Posts Subtitle'); echo parent::em_generate_select_options('em-select-category', __('Select category', 'elegant-magazine'), $categories); echo parent::em_generate_select_options('em-show-excerpt', __('Show excerpt', 'elegant-magazine'), $options); } //print_pre($terms); } } endif;