• Resolved harryf98

    (@harryf98)


    Hello,

    I’m having a problem figuring out how to exclude my hidden Products on my Site. I tried some queries, I found in Stack Overflow, but I can’t figure it out. Here are some screenshots I took:
    https://prntscr.com/rggnyh
    https://prntscr.com/rggnys

    At the moment I’m showing all the products, including the hidden ones.

    Thanks in advance for any help cheers,
    Harry

    The page I need help with: [log in to see the link]

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Support kellymetal a11n

    (@kellymetal)

    Hi there Harry,

    By default, WooCommerce should exclude any hidden products from the shop page and search results, as long as the setting shown in the image below is set:

    hidden
    Link to image: https://d.pr/i/IURjpv

    If your hidden products are showing up on the frontend of the site, then that is most likely being caused by code in a custom theme, or possibly another active plugin on the site.

    To narrow down what is causing the hidden products to be displayed, please temporarily switch your theme back to Storefront and disable all plugins except for WooCommerce, then check to see if the issue is fixed. If it is, then you can switch your theme back and reactivate plugins one-by-one until you find the one that is causing the issue.

    You can read about testing for conflicts in our documentation here:
    https://docs.woocommerce.com/document/how-to-test-for-conflicts/

    I hope that helps!

    Thread Starter harryf98

    (@harryf98)

    I know that but I want t display them somewhere custom and I need a custom query Ifor it. Is there a way because I couldn’t find one yet.

    Thanks in advance!

    • This reply was modified 4 years, 8 months ago by harryf98.
    Plugin Support kellymetal a11n

    (@kellymetal)

    Hi there,

    For a custom query, you could use the wc_get_products function that is described here:
    https://github.com/woocommerce/woocommerce/wiki/wc_get_products-and-WC_Product_Query

    You can read about the visibility parameter in this section

    So, you should be able to use the following to retrieve all visible products.

    
    $args = array(
        'visibility' => 'visible',
    );
    $products = wc_get_products( $args );
    

    I hope that helps!

    Plugin Support kellymetal a11n

    (@kellymetal)

    Hi there,

    We haven’t heard back from you in a while, so I’m going to mark this thread as resolved. If you have any further questions, please start a new thread.

    Have a wonderful day!

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Query Hidden Products’ is closed to new replies.