'primebulletin_grid_post_widget', 'description' => esc_html__('Displays post form selected category specific for popular post in sidebars.', 'primebulletin'), 'customize_selective_refresh' => true, ); $fields = array( 'title' => array( 'label' => esc_html__('Title:', 'primebulletin'), 'type' => 'text', 'class' => 'widefat', ), 'post_category' => array( 'label' => esc_html__('Select Category:', 'primebulletin'), 'type' => 'dropdown-taxonomies', 'show_option_all' => esc_html__('All Categories', 'primebulletin'), ), 'post_number' => array( 'label' => esc_html__('Number of Posts:', 'primebulletin'), 'type' => 'number', 'default' => 12, 'css' => 'max-width:60px;', 'min' => 1, 'max' => 12, ), 'column_number' => array( 'label' => esc_html__('Number of Column:', 'primebulletin'), 'type' => 'select', 'default' => '4', 'options' => array( '2' => esc_html__('2', 'primebulletin'), '3' => esc_html__('3', 'primebulletin'), '4' => esc_html__('4', 'primebulletin'), ), ), ); parent::__construct('PrimeBulletin-grid-1-posts', esc_html__('PrimeBulletin: Layout Grid', 'primebulletin'), $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']; $section_category = isset($params['post_category']) ? $params['post_category'] : ''; $post_number = isset($params['post_number']) ? $params['post_number'] : ''; $column_number = isset($params['column_number']) ? $params['column_number'] : ''; if ($column_number == '2') { $column_class = 6; } else if ($column_number == '3') { $column_class = 4; } else { $column_class = 3; } $home_section_title = isset( $params['title'] ) ? $params['title'] : ''; if( empty( $home_section_title ) && $section_category ){ $home_section_title = get_the_category_by_ID( $section_category ); } $home_section_be = $args['before_title'] . esc_html( $home_section_title ) . $args['after_title']; $grid_post_query = new WP_Query(array('post_type' => 'post', 'posts_per_page' => $post_number, 'post__not_in' => get_option("sticky_posts"), 'cat' => esc_html($section_category))); ?>
have_posts()): while ($grid_post_query->have_posts()) { $grid_post_query->the_post(); $featured_image = wp_get_attachment_image_src(get_post_thumbnail_id(), 'primebulletin-400-280'); $featured_image = isset( $featured_image[0] ) ? $featured_image[0] : ''; ?>
>