Pregunta

I have created a Custom Post Type called Products.

Now I need a functionality that will allow me to select or check a product as featured.
There can be only one featured product.
When one product is selected the others are deselected automatically.
This featured product will be displayed on homepage.

Question:

What is the best way to store the featured_product_id to identify the one that is featured?

¿Fue útil?

Solución

There is no need to store product setting product wise as there will be only one featured product. You can store the featured_product_id in options table. And whenever a product is featured you just override the record in the options table, that why you can avoid the deselecting hassle of previously selected featured product.

Otros consejos

I create an options page and then have a list of all products there where I can choose the product to be featured.

Licenciado bajo: CC-BY-SA con atribución
scroll top