function ac_render_slick_carousel($args, $posts = null) { // Define the defaults $defaults = array('posts_per_page' => 5, 'meta_key' => '_thumbnail_id', 'cat' => '', 'ac_order' => 'order_date_desc', 'show_title' => true, 'show_excerpt' => true, 'excerpt_length' => ''); // Merge in the options $args = wp_parse_args($args, $defaults); // Params to variables extract($args); // Generate our posts if not passed in if ($posts == null) { ac_prepare_args_for_get_posts($args); // Get our posts $posts = get_posts($args); } // Clean up the bool values. Might be "true" $show_title = filter_var($show_title, FILTER_VALIDATE_BOOLEAN); $show_excerpt = filter_var($show_excerpt, FILTER_VALIDATE_BOOLEAN); // Capture and render the output ob_start(); ac_render_slick_carousel_from_posts($posts, $args); $output = ob_get_contents(); ob_end_clean(); return $output; }
function ac_posts_list($args, $posts = null) { global $ac_show_title, $ac_show_excerpt, $ac_show_read_more; // Define the defaults $defaults = array('post_type' => 'post', 'posts_per_page' => 10, 'cat' => '', 'ac_order' => 'order_date_desc', 'show_title' => true, 'show_excerpt' => true, 'show_read_more' => true); // Merge in the options $args = wp_parse_args($args, $defaults); // Params to variables extract($args); // Generate our posts if not passed in if ($posts == null) { ac_prepare_args_for_get_posts($args); // Get our posts $posts = get_posts($args); } // Clean up the bool values. Might be "true" $ac_show_title = filter_var($show_title, FILTER_VALIDATE_BOOLEAN); $ac_show_excerpt = filter_var($show_excerpt, FILTER_VALIDATE_BOOLEAN); $ac_show_read_more = filter_var($show_read_more, FILTER_VALIDATE_BOOLEAN); // Render the output ob_start(); ?> <div class='list-posts'> <?php global $post; foreach ($posts as $post) { // Setup the new post setup_postdata($post); ac_load_post_content(); } wp_reset_postdata(); ?> </div> <?php $output = ob_get_contents(); ob_end_clean(); return $output; }
protected function get_showcase($atts) { global $post, $product; // Merge in the options $defaults = array('posts_per_page' => 4, 'meta_key' => '_thumbnail_id'); $args = wp_parse_args($atts, $defaults); // Showcase is always 4 $args['posts_per_page'] = 4; // Prepare args ac_prepare_args_for_get_posts($args); // Extract the args extract($args); // Clean up the bool values. Might be "true" $show_title = filter_var($show_title, FILTER_VALIDATE_BOOLEAN); // Calc item width, avoid div by zero if ($column_count == 0) { $item_width = '100%'; } else { $item_width = floor(100 / $posts_per_page); $item_width = $item_width . "%;"; } // Pass some values to the template $template_params = compact('item_width', 'show_title', 'column_count'); // Get the posts $posts = get_posts($args); // Post type specifics if ($post_type == 'product') { $items = '<div class="woocommerce ac-showcase">'; $items = '<ul class="products">'; } else { $items = '<div class="ac-showcase">'; } // Render the items foreach ($posts as $post) { setup_postdata($post); // We need to return the content so buffer ob_start(); ac_load_component_content('ac_showcase', $template_params); $items .= ob_get_contents(); ob_end_clean(); } wp_reset_postdata(); if ($post_type == 'product') { $items .= '</ul>'; } $items .= '</div>'; return $items; }
function ac_posts_tile($args, $posts = null) { // Define the defaults $defaults = array('post_type' => 'post', 'posts_per_page' => 12, 'column_count' => 4, 'cat' => '', 'ac_order' => 'order_date_desc', 'show_title' => true, 'show_excerpt' => true, 'excerpt_length' => '', 'meta_key' => '_thumbnail_id', 'link_to_lightbox' => false, 'show_cat_filter' => false, 'post_category' => '', 'layout' => 'posts'); // Merge in the options $args = wp_parse_args($args, $defaults); // Prepare args ac_prepare_args_for_get_posts($args); // Params to variables extract($args); // Generate our posts if not passed in if ($posts == null) { // Get our posts $posts = get_posts($args); } // Calculate the span of each column for desktop if ($column_count != 0) { $cols = 12 / $column_count; } else { $cols = 12; } // Lets set the columns. Ensure the small screens don't have more columns than the larger screens $cols_class = ' col-lg-' . $cols; $cols_class .= ' col-md-' . max($cols, 3); $cols_class .= ' col-sm-' . max($cols, 4); $cols_class .= ' col-xs-' . max($cols, 12); // Grid classes $grid_css = " ac-{$layout} "; // Terms $show_terms = true; // Clean up the bool values. Might be "true" $show_title = filter_var($show_title, FILTER_VALIDATE_BOOLEAN); $show_excerpt = filter_var($show_excerpt, FILTER_VALIDATE_BOOLEAN); $show_cat_filter = filter_var($show_cat_filter, FILTER_VALIDATE_BOOLEAN); // Render the output ob_start(); // Get the terms for these posts // Get all od the term ids for these posts $term_ids = ac_get_terms_for_posts($posts, $post_category); if ($post_category && $show_cat_filter) { echo ac_grids_get_category_filter($post_category, $term_ids); } ?> <?php // NOTE; Bootstrap row not required as tile cols don't have padding ?> <div class='ac-tile-posts ac-filter-target <?php echo $grid_css; ?> ' data-cols='<?php echo $column_count; ?> '> <?php global $post; // Pass some values to the template $template_params = compact('show_title', 'show_excerpt', 'post_category', 'cols_class', 'cols', 'column_count', 'show_terms', 'layout'); foreach ($posts as $post) { setup_postdata($post); // Load the template ac_load_component_content('ac_tile', $template_params); } wp_reset_postdata(); ?> </div> <?php $output = ob_get_contents(); ob_end_clean(); return $output; }