Skip Navigation

[Resolved] Featured Product

This thread is resolved. Here is a description of the problem and solution.

Problem:

Display woocommerce featured product using views.

Solution:

In order to do this you will need to use the following hook


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 the above to your functions.php file and then change the 10 to the id of your view. Once you have done this then you should be able to display your featured product.

This support ticket is created 6 years, 2 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 27 replies, has 2 voices.

Last updated by CharlesB2907 5 years, 11 months ago.

Assisted by: Shane.

Author
Posts
#1134507
Screenshot_10-25-2.jpg

Hi - Can someone please take a look at the attached screenshot and let me know how the "Featured" element in the quick edit panel functions?

Is there any way I can use the function to post a featured image and source Product link?

#1134553

Shane
Supporter

Languages: English (English )

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

Hi Charles,

Thank you for contacting our support forum.

What I know about this is that it is tied to the woocommerce internal system where it is used to mark a product as featured. So if you have a page where you only want to display featured products then this is the setting that you would activate.

Also what do you mean by use the function? Are you referring to the featured product function or the quick edit tab.

Please let me know.

Thanks,
Shane

#1134558

Thank you for the information.

I'm trying to locate the most efficient way for the client to post and update the featured image, product title and product post link on the home page.

I had hoped this would be a way to make that happen.

#1134560

Shane
Supporter

Languages: English (English )

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

Hi Charles,

The easiest way I can think of to do this, since its just the Basic Product Title and Featured image is to create a Toolset Edit form for this and add the edit link to the product.

So what they would need to do is to click the product on the homepage, if the product is their product then an edit link appears. This way they can update the product title and image using out Toolset Forms.

Let me know what you think of this.

Thanks,
Shane

#1134561

This has been a source of great confusion for me for nearly a year now.

The visitor view side and the admin functionality side.

When a website visitor views this Home Page: hidden link

They should be able to click the button "View This Work" and open the Product page associated with the Image on the left.

How to edit this page other than from the admin dashboard is still confusing. But that is a separate question.

Thanks.

#1135078

Shane
Supporter

Languages: English (English )

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

Hi Charles,

I took a look at how you set this up.

Actually I would not recommend this method that you're currently doing, as its very static.

On the homepage what exactly should be displayed? The Latest product ?

Please let me know as I can assist you with setting up a template that should get this working properly for you.

Thanks,
Shane

#1135129

Hi Shane,

Thank you. I appreciate the assistance. A little history:

The old website consists of over a 1000+ Project post-type pages, each to display a profile of the artists work, that I migrated over to the new installation for staging. I've been converting those Project pages to Product post-type pages in the staging site. I use a custom template that I created with Divi Builder the Product page (I hope this part is not incorrect because I've already completed about 100 and I am working on converting the remaining 900+ old project files).

1. The artist wants to, as frequently as he chooses) post one of the art Product profiles (randomly to the Home Page ( to display in the Home Page layout created (also currently as a custom template). I would like to make it as easy as possible for the client to post his work as the featured work on the HP.

2. I want visitors to the site to be able to access a form, that I would like to place on a Divi screen overlay that would display when the visitor clicked the button or menu link market as "Search Other Work".

3. Once the above is completed, I plan to proceed to integrate the woocommerce "add to cart" functionality.

One of your colleagues has suggested that I set up the search as a static page rather than a custom search.

Any help you can provide, having viewed the project as you have, would be greatly appreciated.

Please let me know asap if I should discontinue the converting the old Project pages to Product pages.

#1135130

I'd like to point out that the backend for the staging site contains a lot of plugins and files that migrated over. I plan to remove unnecessary elements once the basic staging of the Toolset integration is complete which should be based primarily on the Product post-type pages and the Home Page where a single Product will be featured periodically by owner selection.

I hope this helps.

#1135158

Shane
Supporter

Languages: English (English )

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

Hi Charles,

Here is a look at a dynamic one that i've setup where the View project button is working.
hidden link

This is the view I used the feed the display.
hidden link

This is the content template that i've added to allow for it to be displayed on the homepage.
hidden link

So essentially I'm using a view to display the items on the frontpage and to generate the image and the link to the page. This way you won't need to hardcode the links.

Please let me know what you think.

Thanks,
Shane

#1135184
Screenshot_10-23-2.jpg

Hi - Thank you.

The first thing I noticed was that the Home Page link you provided no longer has the Divi Builder styling that I had originally created for the client. I have not had time to look over the set-up you provided to see with the styling CSS implemented can be added. If can't, unfortunately, the client will not accept it's current state. The Home Page must appear as it did in the layout screenshot attached.

The link you provided on for View This Work is absolutely PERFECT. I just need to get the styling back. I had added custom CSS to set a maximum page height for the Home page featured image.

I know Toolset is about to go to weekend mode but I will try to see if I can style the workflow that you provided.

Thank you for this lead. I really appreciate your help. This is a visually demanding design.

#1135216

First Update:

I was able to trace the View you created for the Home Page and replace its template with the client approved layout which works great. I'm still studying the remaining workflow but this was a huge step forward. Will update this thread with more feedback as soon as possible.

HUGE Thank you.

#1135395
Screenshot 10-26-1.jpg

This seems great but I can't see where to change the featured content on the Home Page.

I changed the three field elements as shown in the screenshot but the displayed image, title and url did not change on the actual Home Page. I'm sure I must be looking in the wrong place. Can you please point it out?

#1136072

Shane
Supporter

Languages: English (English )

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

Hi Charles,

I see what you are saying.

However, what I did was to set it to automatically pull items from the products. hidden link

So instead of manually setting up this each time the customer wants to change their featured product. This is done automatically.

Essentially these fields are not needed. I'm essentially displaying parts of the product itself.

Please let me know if this is clear.

#1136078

I'm very confused now. I do not know what you mean by automatically pull items from the Products.

For example, I do not know how the current Product on the Home Page is posted and I do not know how to change it.

Products should not be posted to the Home Page unless I or the client selected a Product to be featured. There are many reasons for featuring a Product. The featured Product must be selected and posted manually and not be automatic.

Does this make sense and how can I accomplish this?

#1136083

Shane
Supporter

Languages: English (English )

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

Screenshot 2018-10-29 at 9.51.11 AM.png

Hi Charles,

Lets clear up some of the confusion.

1. What you were doing previously.

In your setup before you opened the ticket. You were manually opening the homepage and editing what you wanted to display as the featured item, each time you wanted to change the product.

2. What I did

What I did was to essentially automate this process somewhat. Instead of you having to manually enter the information on the homepage. I went ahead and created this view below.
hidden link

So I told this view to pull the first item and display it. Now each time you add a new Product the item on the frontend will change and the View This Work link will change as well automatically.

I did this essentially as a proof of concept to help automate this. What we need now is a way to determine which product will display.

We can use the woocommerce default Feature Item option. This column here. See Screenshot

So if your customer is ok with this, then I can just edit the view to display only the item that has been marked as featured. So instead of you editing the homepage and finding the link for the item. You can just go to the list of products and mark the featured item .

Then the homepage will update automatically.

Please let me know if this is clear.

Thanks,
Shane