function widget($args, $instance) { extract($args, EXTR_SKIP); // Title $title = $instance['title']; // Build query $query = $instance['query']; if (!$query) { $instance['category'] == 'all' ? $category = '' : ($category = $instance['category']); $query = 'category_name=' . $category; $query .= '&numberposts=' . $instance['numberposts']; $query .= '&suppress_filters=false'; // Mainly for WPML compat } // Widget output echo $before_widget; if ($title) { echo $before_title . $title . $after_title; } echo themeblvd_get_mini_post_grid($query, $instance['align'], $instance['thumb'], $instance['gallery']); echo $after_widget; }
/** * Mini Post Grid * * @since 1.0.0 * * @param array $atts Standard WordPress shortcode attributes * @return string $output Content to output for shortcode */ function themeblvd_shortcode_mini_post_grid($atts) { // Default shortcode atts $default = array('categories' => '', 'cat' => '', 'category_name' => '', 'tag' => '', 'numberposts' => 4, 'orderby' => 'date', 'order' => 'DESC', 'offset' => 0, 'query' => '', 'thumb' => 'smaller', 'align' => 'left', 'gallery' => ''); extract(shortcode_atts($default, $atts)); // Build query if (!$query) { // Categories if ($categories) { // @deprecated $query .= 'category_name=' . $categories . '&'; } if ($cat) { $query .= 'cat=' . $cat . '&'; } if ($category_name) { $query .= 'category_name=' . $category_name . '&'; } // Tags if ($tag) { $query .= 'tag=' . $tag . '&'; } // Continue query $query .= 'numberposts=' . $numberposts . '&'; $query .= 'orderby=' . $orderby . '&'; $query .= 'order=' . $order . '&'; $query .= 'offset=' . $offset . '&'; $query .= 'suppress_filters=false'; // Mainly for WPML compat } if ($gallery) { $gallery = sprintf('[gallery ids="%s" link="file"]', $gallery); } // Output $output = themeblvd_get_mini_post_grid($query, $align, $thumb, $gallery); return $output; }
/** * Display Mini Post Grid * * @since 2.1.0 * * @param array $options Options for many post grid */ function themeblvd_mini_post_grid($query = '', $align = 'left', $thumb = 'smaller', $gallery = '') { echo themeblvd_get_mini_post_grid($query, $align, $thumb, $gallery); }