Ejboparkens tilbuds side

function salgstrappe_sale_products_shortcode($atts) {
$atts = shortcode_atts(array(
‘per_page’ => ’12’,
‘columns’ => ‘4’,
), $atts, ‘salgstrappe_products’);

$args = array(
‘post_type’ => ‘product’,
‘posts_per_page’ => intval($atts[‘per_page’]),
‘meta_query’ => array(
array(
‘key’ => ‘_stomWS_is_part_of_salgstrappe’,
‘value’ => ‘yes’,
‘compare’ => ‘=’
),
array(
‘key’ => ‘_sale_price’,
‘value’ => 0,
‘compare’ => ‘>’,
‘type’ => ‘NUMERIC’
)
)
);

ob_start();
$products = new WP_Query($args);

if ($products->have_posts()) {
echo ‘

    ‘;
    while ($products->have_posts()) {
    $products->the_post();
    wc_get_template_part(‘content’, ‘product’);
    }
    echo ‘

‘;
} else {
echo ‘

Ingen produkter fundet i salgstrappen.

‘;
}
wp_reset_postdata();
return ob_get_clean();
}
add_shortcode(‘salgstrappe_products’, ‘salgstrappe_sale_products_shortcode’);