Home › Forums › General Issues › How can I exclude extra relationship posts from Woocommerce archive loop? › Reply To: How can I exclude extra relationship posts from Woocommerce archive loop?
What you have planned is a solution, but it could impact the performance of your site significantly if you have a lot of products to deal with and could eventually cause the page to time out.
The easiest fix for this is to add another ACF field, I would use a true/false that I would use to either include of exclude the product from archives. The client would need to set this field when they are adding the relationships. With the addition of this field you could then add a simple meta_query to the main WP query for WC to select the products that get shown. This would mean a little extra work for the client.
Another more complicated option would be to store your “post__not_in” array in a transient so that the value does not need to be regenerated on every page load.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Cookie Policy. If you continue to use this site, you consent to our use of cookies.