예제 #1
0
파일: list-post.php 프로젝트: alysilv/sila
<div class="content clearfix">
 <?php 
$settings['image_size'] = 'st_medium';
if (have_posts()) {
    while (have_posts()) {
        the_post();
        ?>
    <?php 
        include ST_TEMPLATE_DIR . 'loop/loop-post.php';
        ?>
 <?php 
    }
    ?>
 
 <div class="pagination pagination-right text-right t40">
  <?php 
    st_post_pagination();
    ?>
  </div>
  <?php 
} else {
    ?>
    <?php 
    // not found
    ?>
 <?php 
}
?>
 
</div>
예제 #2
0
 /**
  * BP WC Products
  */
 function st_wc_products_func($atts, $content = '')
 {
     global $wp_query, $woocommerce;
     global $post, $paged;
     $tmp_post = $post;
     $atts = shortcode_atts(array('cats' => array(), 'number' => 3, 'columns' => 3, 'exclude' => '', 'include' => '', 'offset' => 0, 'pagination' => 'no', 'hide_free' => 'yes', 'order_by' => 'ID', 'order' => 'DESC'), $atts);
     extract($atts);
     if (!st_is_woocommerce()) {
         return '';
     }
     $html = $cat_link = $cat_title = '';
     // just only for one cate
     if (is_string($cats)) {
         $cats = explode(',', $cats);
     }
     $cats = $cats[0];
     if (intval($number) <= 0) {
         $number = (int) get_option('posts_per_page', 10);
     } else {
         $number = intval($number);
     }
     $args = array('posts_per_page' => (int) $number, 'offset' => (int) $offset);
     if ($cats > 0) {
         $args['tax_query'] = array('relation' => 'AND', array('taxonomy' => 'product_cat', 'field' => 'id', 'terms' => array($cats), 'operator' => 'IN'));
     }
     $exclude = $exclude != '' ? explode(',', $exclude) : $exclude;
     $include = $include != '' ? explode(',', $include) : $include;
     $args['post__not_in'] = $exclude;
     $args['post__in'] = $include;
     // custom order by meta key
     if (isset($order_by[0]) && $order_by[0] == '_') {
         $order_by = substr($order_by, 1);
         $args['meta_key'] = $order_by;
         $args['orderby'] = 'meta_value_num';
         $args['meta_query'] = array();
         if ($hide_free == 'yes') {
             $args['meta_query'][] = array('key' => '_price', 'value' => 0, 'compare' => '>', 'type' => 'DECIMAL');
         }
         $args['meta_query'][] = $woocommerce->query->stock_status_meta_query();
         $args['meta_query'][] = $woocommerce->query->visibility_meta_query();
     } else {
         $args['orderby'] = $order_by;
     }
     $args['order'] = $order;
     if ($paged > 0) {
         $args['paged'] = $paged;
     } else {
         $paged = isset($_REQUEST['paged']) ? intval($_REQUEST['paged']) : 1;
         $args['paged'] = $paged;
     }
     $args['post_type'] = 'product';
     $args['post_status'] = 'publish';
     if (st_is_wpml()) {
         $args['sippress_filters'] = true;
         $args['language'] = get_bloginfo('language');
     }
     $new_query = new WP_Query($args);
     $myposts = $new_query->posts;
     $i = 0;
     $e = '';
     ob_start();
     $old_content = ob_get_clean();
     if ($type == 3 && count($myposts) % 2 != 0) {
         $myposts[] = false;
     }
     // $image_size = 'large'; // ***
     // show columns
     $columns = intval($columns);
     $columns = $columns > 0 && $columns <= 6 ? $columns : 6;
     // echo $num_col; die();
     global $woocommerce_loop;
     $woocommerce_loop['columns'] = $columns;
     //apply_filters( 'loop_shop_columns', $columns );
     foreach ($myposts as $post) {
         setup_postdata($post);
         global $product;
         $tpl = '';
         ob_start();
         woocommerce_get_template_part('content', 'product');
         $tpl = ob_get_clean();
         $e .= $tpl;
         $i++;
     }
     $html .= $e;
     $html = '<div class="products row">' . $html . '</div>';
     $p = '';
     // if(!is_home() && !is_front_page()) { // only true if not is home page or front page
     if ($pagination == 'yes') {
         $p = st_post_pagination($new_query->max_num_pages, 2, false);
         if ($p != '') {
             $p = '<div class="st-pagination-wrap ">' . $p . '</div>';
         }
     }
     // }
     wp_reset_query();
     echo $old_content;
     $post = $tmp_post;
     setup_postdata($post);
     $html = '<div class="woocommerce-wrap woocommerce  builder-item-wrapper">' . do_shortcode($html) . $p . '</div>';
     $html = apply_filters('st_wc_products_func', $html, $atts);
     return $html;
 }
예제 #3
0
파일: shortcode.php 프로젝트: alysilv/sila
function st_events_func($atts, $content = '')
{
    global $wp_query;
    global $post, $paged;
    $tmp_post = $post;
    extract(shortcode_atts(array('title' => '', 'cats' => '', 'numpost' => 5, 'exclude' => '', 'orderby' => '_st_event_start_date', 'order' => 'DESC', 'pbwith' => '1_1', 'type' => 1, 'site_layout' => '', 'show_title' => 'n', 'show_paging' => 'n'), $atts));
    // $wc = $builder[$i]['pbwith']; old
    $wc = $pbwith;
    // new
    $w = explode('_', $wc);
    $t = intval($w[0]);
    $m = intval($w[1]);
    if ($m > 0 and $t > 0) {
        $c = $t / $m;
    } else {
        $c = 1;
    }
    $html = '';
    // just only for one cate
    if (is_string($cats)) {
        $cats = explode(',', $cats);
    }
    if ($title != '') {
        $html .= '<div class="builder-title-wrapper clearfix">
                        <h3 class="builder-item-title">' . esc_html($title) . '</h3>
                    </div>';
    }
    if (intval($numpost) <= 0) {
        $numpost = (int) get_option('posts_per_page', 10);
    } else {
        $numpost = intval($numpost);
    }
    $args = array('posts_per_page' => $numpost);
    if ($cats > 0) {
        // $args['category__in'] =  array($cats);
    }
    if ($exclude != '') {
        $exclude = explode(',', $exclude);
        $args['post__not_in'] = $exclude;
    }
    if ($orderby == '_st_event_start_date' || $orderby == '_st_event_end_date') {
        $args['meta_key'] = $orderby;
        $args['meta_query'] = array(array('key' => $orderby, 'value' => '1000-01-01 00:00', 'compare' => '>=', 'type' => 'DATETIME'));
        $args['orderby'] = 'meta_value';
    } else {
        $args['orderby'] = $orderby;
    }
    $args['order'] = $order;
    $args['post_type'] = 'event';
    if ($paged > 0) {
        $args['paged'] = $paged;
    } else {
        $paged = isset($_REQUEST['paged']) ? intval($_REQUEST['paged']) : 1;
    }
    // added in ver 1.3
    if (st_is_wpml()) {
        $args['sippress_filters'] = true;
        $args['language'] = get_bloginfo('language');
    }
    $new_query = new WP_Query($args);
    $myposts = $new_query->posts;
    $e = '';
    $template_file = ST_TEMPLATE_DIR . 'loop/loop-event.php';
    // display as list
    foreach ($myposts as $post) {
        setup_postdata($post);
        $e .= st_get_content($template_file);
        $i++;
    }
    $html .= $e;
    $p = '';
    if (!is_home() && !is_front_page()) {
        // only true if not is home page or front page
        if ($show_paging == 'y') {
            $p = st_post_pagination($new_query->max_num_pages, 2, false);
            if ($p != '') {
                $p = '<div class="pagination text-center t0">' . $p . '</div>';
            }
        }
    }
    wp_reset_postdata();
    return '<div class="loop-events">' . do_shortcode($html) . $p . '</div>';
}
예제 #4
0
/** ******************** Shorcode for page builder******************************** */
function st_blog_post_func($atts, $content = '')
{
    global $wp_query;
    global $post, $paged;
    $tmp_post = $post;
    extract(shortcode_atts(array('title' => '', 'cats' => array(), 'numpost' => 5, 'exclude' => '', 'orderby' => 'ID', 'order' => 'DESC', 'pbwith' => '1_1', 'type' => 1, 'site_layout' => '', 'show_title' => 'n', 'show_paging' => 'n'), $atts));
    // $wc = $builder[$i]['pbwith']; old
    $wc = $pbwith;
    // new
    $w = explode('_', $wc);
    $t = intval($w[0]);
    $m = intval($w[1]);
    if ($m > 0 and $t > 0) {
        $c = $t / $m;
    } else {
        $c = 1;
    }
    $html = '';
    // just only for one cate
    if (is_string($cats)) {
        $cats = explode(',', $cats);
    }
    if (is_array($cats) && count($cats) > 0) {
        $cat = $cats[0];
        $cat_link = $cat_title = '';
        if ($cat > 0) {
            $cat_link = get_category_link($cat);
            $cat_title = get_cat_name($cat);
        } else {
            // do some thing
        }
        if (in_array(0, $cats)) {
            $cats = array();
        }
    }
    if ($title != '') {
        $html = '
             <div class="builder-title-wrapper clearfix">
                <h3 class="builder-item-title">' . esc_html($title) . '</h3>
             </div>
             ';
    } elseif (isset($cat_link) && isset($cat_link) && $cat_link && $cat_title) {
        $html = '';
    }
    if (intval($numpost) <= 0) {
        $numpost = (int) get_option('posts_per_page', 10);
    } else {
        $numpost = intval($numpost);
    }
    $args = array('posts_per_page' => $numpost);
    if ($cats > 0) {
        $args['category__in'] = $cats;
    }
    if ($exclude != '') {
        $exclude = explode(',', $exclude);
    }
    $args['post__not_in'] = $exclude;
    $args['orderby'] = $orderby;
    $args['order'] = $order;
    if ($paged > 0) {
        $args['paged'] = $paged;
    } else {
        $paged = isset($_REQUEST['paged']) ? intval($_REQUEST['paged']) : 1;
    }
    // added in ver 1.3
    if (st_is_wpml()) {
        $args['sippress_filters'] = true;
        $args['language'] = get_bloginfo('language');
    }
    $new_query = new WP_Query($args);
    $myposts = $new_query->posts;
    $i = 0;
    if ($type == 2) {
    }
    $e = '';
    $c = 0;
    if ($type == 3 && count($myposts) % 2 != 0) {
        $myposts[] = false;
    }
    $image_size = '';
    if ($site_layout == 1 && ($pbwith == '1_1' || $pbwith == '3_4') && $type != 3) {
        $image_size = 'st_large';
    }
    // display as list
    foreach ($myposts as $post) {
        setup_postdata($post);
        if ($type == 3) {
            if ($c == 0) {
                $e .= '<div class="row">';
                $e .= '<div class="six columns b20">' . st_get_content(ST_TEMPLATE_DIR . 'loop/loop-post.php', $post, array('display_type' => $type, 'i' => $i, 'image_size' => $image_size)) . '</div>';
                $c++;
            } else {
                $e .= '<div class="six columns b20">' . st_get_content(ST_TEMPLATE_DIR . 'loop/loop-post.php', $post, array('display_type' => $type, 'i' => $i, 'image_size' => $image_size)) . '</div>';
                $e .= '<div class="clear"></div></div>';
                $c = 0;
            }
        } else {
            $e .= st_get_content(ST_TEMPLATE_DIR . 'loop/loop-post.php', $post, array('display_type' => $type, 'i' => $i, 'image_size' => $image_size));
        }
        $i++;
    }
    $html .= '<div class="loop-posts">' . $e . '</div>';
    $p = '';
    if (!is_home() && !is_front_page()) {
        // only true if not is home page or front page
        if ($show_paging == 'y') {
            $p = st_post_pagination($new_query->max_num_pages, 2, false);
            if ($p != '') {
                $p = '<div class="pagination text-left t0">' . $p . '</div>';
            }
        }