'allinone_post_widget', 'description' => esc_html__('Displays posts from selected category in different featured layouts.', 'allinone'), 'customize_selective_refresh' => true, ); $fields = array( 'title' => array( 'label' => esc_html__('Section Title:', 'allinone'), 'type' => 'text', 'class' => 'widefat', ), 'post_category' => array( 'label' => esc_html__('Select Category:', 'allinone'), 'type' => 'dropdown-taxonomies', 'show_option_all' => esc_html__('All Categories', 'allinone'), ), 'display_orientation' => array( 'label' => esc_html__('Display Layout:', 'allinone'), 'type' => 'select', 'default' => 'layout-1', 'options' => array( 'layout-1' => esc_html__('Layout - 1 ', 'allinone'), 'layout-2' => esc_html__('Layout - 2', 'allinone'), 'layout-3' => esc_html__('Layout - 3', 'allinone'), 'layout-4' => esc_html__('Layout - 4', 'allinone'), 'layout-5' => esc_html__('Layout - 5', 'allinone'), ), ), 'enable_meta' => array( 'label' => esc_html__('Enable Categories:', 'allinone'), 'type' => 'checkbox', 'default' => true, ), 'enable_meta_1' => array( 'label' => esc_html__('Enable Date & Author:', 'allinone'), 'type' => 'checkbox', 'default' => true, ), 'button_text' => array( 'label' => esc_html__('Button Text:', 'allinone'), 'type' => 'text', 'default' => 'View more', 'class' => 'widefat', ), ); parent::__construct('allinone-widget-style-1', esc_html__('Allinone: Featured Blocks', 'allinone'), $opts, array(), $fields); } /** * Outputs the content for the current widget instance. * * @param array $args Display arguments. * @param array $instance Settings for the current widget instance. * @since 1.0.0 * */ function widget($args, $instance) { $params = $this->get_params($instance); echo $args['before_widget']; if ($params['display_orientation'] == 'layout-1') { $post_number = 2; } elseif ($params['display_orientation'] == 'layout-2') { $post_number = 5; } elseif ($params['display_orientation'] == 'layout-4') { $post_number = 7; } elseif ($params['display_orientation'] == 'layout-5') { $post_number = 8; } else { $post_number = 4; } $qargs = array( 'post_type' => 'post', 'posts_per_page' => $post_number, 'post__not_in' => get_option("sticky_posts"), ); $cat_link = ""; if (absint($params['post_category']) > 0) { $qargs['cat'] = absint($params['post_category']); $cat_link = get_category_link($params['post_category']); } $style_1_posts_query = new WP_Query($qargs); if ($style_1_posts_query->have_posts()) : ?>

have_posts()) : $style_1_posts_query->the_post(); ?>
>

'; echo esc_html(wp_trim_words(get_the_content(), 20, '...')); echo '

'; } ?>

have_posts()) : $style_1_posts_query->the_post(); ?>
>

'; echo esc_html(wp_trim_words(get_the_content(), 20, '...')); echo '

'; } ?>
current_post + 1 == $style_1_posts_query->post_count) { echo '
'; } ?>

have_posts()) : $style_1_posts_query->the_post(); ?>
>

'; echo esc_html(wp_trim_words(get_the_content(), 20, '...')); echo '

'; } ?>
current_post + 1 == $style_1_posts_query->post_count) { echo '
'; } ?>

have_posts()) : $style_1_posts_query->the_post(); ?>
>

'; echo esc_html(wp_trim_words(get_the_content(), 20, '...')); echo '

'; } ?>
current_post + 1 == $style_1_posts_query->post_count) { echo '
'; } ?>

have_posts()) : $style_1_posts_query->the_post(); ?>
current_post + 1 == $style_1_posts_query->post_count) { echo '
'; } ?>