mircobabini
12/3/2014 - 6:23 PM

snippet.wordpress.woocommerce.filter_archive.php

<?php
/* prepare and perform the new query (only if WPML is NOT active) */
global $wp_query;
$query_vars = $wp_query->query_vars;
$query_vars['posts_per_page'] = -1;
$query_vars['meta_key']   = 'my_meta_key';
$query_vars['meta_value'] = 'my_meta_value';
$wp_query = new WP_Query( $query_vars );
/* and the query is done */
?>
<?php if ( have_posts() ) : ?>
	<?php while ( have_posts() ) : the_post(); ?>
	<?php /* filter the results (only if WPML is active) */ ?>

	<?php
		global $sitepress;
		$id = icl_object_id( get_the_ID(), 'product', false, $sitepress->get_default_language() );
		$show = get_post_meta( $id, 'my_meta_key', true );
		if( ! $show || $show != 'my_meta_value' ){
			continue;
		}
	?>
	
	<?php woocommerce_get_template_part( 'content', 'product' ); ?>

	<?php /* and the results are filtered */ ?>
	<?php endwhile; // end of the loop. ?>

<?php else : ?>

<?php endif; ?>