function wpb_wps_sideber_feature_shortcode($atts)
{
    extract(shortcode_atts(array('posts' => 5), $atts));
    $return_string = '<div class="wpb_slider_area wpb_sidebar_slider owl-text-center wpb_fix_cart">';
    $return_string .= '<div id="owl-demo-side-feature" class="owl-carousel">';
    $args = array('post_type' => 'product', 'meta_key' => '_featured', 'meta_value' => 'yes', 'posts_per_page' => $posts);
    $loop = new WP_Query($args);
    if ($loop->have_posts()) {
        while ($loop->have_posts()) {
            $loop->the_post();
            global $product;
            $return_string .= '<div class="item">';
            $return_string .= '<figure>';
            if (!defined('ABSPATH')) {
                exit;
            }
            // Exit if accessed directly
            global $post, $product;
            $return_string .= '<a href="' . get_permalink() . '" class="wpb_pro_img_url">';
            if (has_post_thumbnail($loop->post->ID)) {
                $return_string .= get_the_post_thumbnail($loop->post->ID, 'wpb-pro-thumb', array('class' => "wpb_pro_img"));
            } else {
                $return_string .= '<img id="place_holder_thm" src="' . woocommerce_placeholder_img_src() . '" alt="Placeholder" />';
            }
            $return_string .= '</a>';
            $return_string .= '<figcaption>';
            $return_string .= '<h3 class="pro_title">';
            if (strlen($post->post_title) > 20) {
                $return_string .= substr(the_title($before = '', $after = '', FALSE), 0, wpb_ez_get_option('wpb_title_mx_ch', 'wpb_wps_style', 10)) . '...';
            } else {
                $return_string .= get_the_title();
            }
            $return_string .= '</h3>';
            $return_string .= '<div class="price_area_fix">' . do_shortcode('[add_to_cart id="' . get_the_ID() . '"]') . '</div>';
            // call cart btn and price
            $return_string .= '</figcaption>';
            $return_string .= '</figure>';
            $return_string .= '</div>';
        }
    } else {
        echo __('No products found');
    }
    wp_reset_postdata();
    $return_string .= '</div>';
    $return_string .= '</div>';
    wp_reset_query();
    return $return_string;
}
示例#2
0
function wpb_settings_style()
{
    ?>
<style type="text/css">
.grid figcaption a, div.grid_no_animation figcaption a.button {background: <?php 
    echo wpb_ez_get_option('wpb_wps_btn_bg', 'wpb_wps_style', '#1abc9c');
    ?>
!important;}
.grid figcaption a:hover, div.grid_no_animation figcaption a.button:hover {background: <?php 
    echo wpb_ez_get_option('wpb_wps_btn_bg_hover', 'wpb_wps_style', '#16a085');
    ?>
!important;}
.owl-theme .owl-controls .owl-page span {background: <?php 
    echo wpb_ez_get_option('wpb_pagi_btn_bg', 'wpb_wps_style', '#8BCFC2');
    ?>
;}
.owl-theme .owl-controls .owl-page.active span,
.owl-theme .owl-controls.clickable .owl-page:hover span{background: <?php 
    echo wpb_ez_get_option('wpb_pagi_btn_bg_ac', 'wpb_wps_style', '#16A085');
    ?>
;}
.owl-theme .owl-controls .owl-buttons div {background: <?php 
    echo wpb_ez_get_option('wpb_nav_btn_bg', 'wpb_wps_style', '#CCCCCC');
    ?>
;}
.owl-theme .owl-controls.clickable .owl-buttons div:hover{background:<?php 
    echo wpb_ez_get_option('wpb_nav_btn_bg_ac', 'wpb_wps_style', '#999999');
    ?>
;}
div.grid_no_animation figcaption .pro_price_area .amount {text-decoration: none;color: <?php 
    echo wpb_ez_get_option('wpb_pro_price_color_i', 'wpb_wps_style', '#16A085');
    ?>
;}
</style>
<?php 
}