Shane
Supporter
Languages:
English (English )
Timezone:
America/Jamaica (GMT-05:00)
Hello,
The solution here:
add_filter( 'wpv_filter_query', 'featured_products',99,3 );
function featured_products( $query_args,$views_settings, $view_id) {
if ($view_id == 10){
$query_args = array(
'post_type' => 'product',
'tax_query' => array(
array(
'taxonomy' => 'product_visibility',
'field' => 'name',
'terms' => 'featured',
'operator' => 'IN'
),
),
);
}
return $query_args;
}
I've tested it and it works fine here hidden link
I created a test view and as you can see only the featured one shows up.
Thanks,
Shane
Hi Shane,
Thanks for the work. Are you referring the result shown in image 1?
I'm so sorry to say but do not want just a name for featured image I want to use featured products in slider with clickable url image. Just like the featured product section on home page. (see image 2)
I've developed this section but it's not dynamic. I have to add the product each time in this section manually.
Shane
Supporter
Languages:
English (English )
Timezone:
America/Jamaica (GMT-05:00)
Hello,
The page was just an example. I created the view and only set it to list out the product title.
What you need to do is create a view that will display the products how you want it. It was just an example to show that the code to allow the view to display the featured product is working.
Have you already setup a view on how you want the products to display?
Please let me know.
Thanks,
Shane
Hi Shane,
This work is already done by me long ago. Featured products are showing up but only title not pictures.
Thank you
Shane
Supporter
Languages:
English (English )
Timezone:
America/Jamaica (GMT-05:00)
Hello,
But from my observation below there are no views on this
hidden link
Could you let me know where you have setup this so that I can have a look ? This way I can let you know how to add the images?
Thanks,
Shane
Because I constantly update website. I need the solution for this so I have temporary show featured products on my home page.
You have all the scenario and even access to webpage kindly provide the solution for this problem.
Thank you
If you are not able to resolve it kindly transfer me to NIGEl from Europe, so far one of the best supporter in your team.
Shane
Supporter
Languages:
English (English )
Timezone:
America/Jamaica (GMT-05:00)
Hello,
I've provided the solution multiple times.
To display the featured items with views you need to use the following filter.
add_filter( 'wpv_filter_query', 'featured_products',99,3 );
function featured_products( $query_args,$views_settings, $view_id) {
if ($view_id == 10){
$query_args = array(
'post_type' => 'product',
'tax_query' => array(
array(
'taxonomy' => 'product_visibility',
'field' => 'name',
'terms' => 'featured',
'operator' => 'IN'
),
),
);
}
return $query_args;
}
This code is to be added to your functions.php file after you've created your view to display the products. Once this custom filter has been added then replace the view id in the code with the ID of your created view. This will cause that view to ONLY display your products that are marked as featured.
Is it that you're not sure how to create this view ? Please let me know so that I can provide assistance with this as well.
I'm was under the impression that you've already created this view but just wanted to filter for the featured items.
Looking forward to hearing from you soon.
Thanks,
Shane
My issue is resolved now. Thank you!