I'm working on a custom built English website that has WPML integrated in it to get the French translations for the entire site which also includes various custom post types, the main one I'm trying to get to work with it properly is the cpt "Products". So I already have the site translated but where my issue resides is with the custom search form & page that should only pull the cpt "Products".
Whenever I search for a product whether by ID or name, all products relating to the search is pulled as it should BUT is pulled for both languages. I only want it to show English results if it's on the English site and vice-versa for the French site but to no avail I can't get it to work.
CODE Snippet from Search Page:
if (have_posts()) {
$col_count = 1;
echo '
<div class="product-archive">
';
while(have_posts()) {
the_post();
if ($post->post_type == 'product') {
if (has_post_thumbnail($post->ID)) {
$thumbnail = get_the_post_thumbnail_url($post->ID);
} else {
$thumbnail = plugins_url('../images/gcp-no-thumbnail.jpg', __FILE__);
}
if ($col_count == 1) {
/*
echo '
<div class="product-row">
';
*/
}
echo '
<div class="col-sm-' . $column_size . ' product-category">
<a class="borderOutside" href="' . get_permalink($post->ID) . '">
<div class="borderInside">
<img src="' . $thumbnail . '" alt="' . $post->post_title . '">
<h2>' . $post->post_title . '</h2>
</div>
</a>
</div>
';
$col_count++;
if ($col_count > $columns) {
/*
echo '
</div>
';
*/
$col_count = 1;
}
}
}
echo '
</div>
';
}
?>
</article>