<?php if ( have_posts() ) : ?>
<?php while ( have_posts() ): the_post();
setcookie('sw_products_view', 'grid');
if(!isset($_COOKIE['sw_products_view'])) {
// set a cookie for 1 year
setcookie('sw_products_view', 'grid');
}
$view = $_COOKIE['sw_products_view'];
$id_list = 593;
$id_grid = 503;
$frontend = new \Elementor\Frontend();
if ($view=='list'){
echo $frontend->get_builder_content_for_display( $id_list , true );
}else{
echo $frontend->get_builder_content_for_display( $id_grid, true );
}
?>
<?php endwhile; ?>
<?php else : ?>
<p><?php _e( 'Sorry, no posts matched your criteria.' ); ?></p>
<?php endif; ?>
