Skip Navigation

[Resolved] Home Page View – Featured Product Display

This support ticket is created 5 years, 11 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 -
- 13:00 – 18:00 13:00 – 18:00 13:00 – 18:00 14:00 – 18:00 13:00 – 18:00 -

Supporter timezone: America/Jamaica (GMT-05:00)

This topic contains 5 replies, has 2 voices.

Last updated by Shane 5 years, 11 months ago.

Assisted by: Shane.

Author
Posts
#1190610

Hi,

I have a new issue related to a previously [Resolved} Featured Product support ticket. That ticket URL https://toolset.com/forums/topic/featured-product/ involved the automatic selection and posting of a single featured product image and related fields on the Home Page by selecting the product from the Product list panel in the wp-admin as indicated in reply dated October 29, 2018 at 8:12 pm #1136223

I've tried exporting Toolset Modules from the source site indicated in the original ticket and imported them to another project but I am unable to recreate the previous development because of not knowing where to add the filter as indicated in Reply #1136223 :

"... just add this filter so that the view will filter only the Featured Products."

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;
}

The work of the original support agent resolved the issue perfectly and I would like to record exactly how to duplicate it in new projects. Please that there is a second question closely related to the same featured product subject for the Home Page and it would be very helpful if I can submit it to the same support agent that resolves this ticket as it is directly related.

Thank you,

#1190679

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Charles,

Thank you for getting in touch.

You're saying that you want to apply this setup to another site.

Have you already created a view that will list the featured product? If so all that is needed is to just add the filter below.

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;
}

Add it to your site and then change the 10 to the ID of your new view.

Thanks,
Shane

#1190724

Shane,

Thank you for picking this ticket up. I assume you mean to add the script to the functions.php file for the site?

Also, there is another ticket directly related to the same view issue. Are you able to pick it up as well?

#1190731

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Charles,

Yes that is correct.

Thanks,
Shane

#1190732

I added the filter as you indicated and this portion of the issue is resolved. I can now effectively select the featured image from the product list panel. I can not bookmark the complete workflow for new projects. Thank you.

The other issue pertains to displaying the same featured image in the top full-width module in the same view where I am using a Divi Full Width Header Module which is currently in use displaying a static file of the same featured product.

#1190754

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Charles,

I've responded to the issue about the featured image in the appropriate ticket.

Thanks,
Shane