• I’m really new to php editing but I’m trying to learn. My woocommerce products that are set to “hidden” under catalog visibility are still showing up under search results. How do I keep hidden products out of my search results? I found this thread and tried adding the below code mentioned at the bottom of the thread (I’m using Woocommerce 3.2.1) to my child theme’s functions.php file. It gave me the white screen of death and this error: Parse error: syntax error, unexpected ‘=>’ (T_DOUBLE_ARROW). Based on some google searches, it seems this woocommerce functionality was recently changed from a meta query to a tax query in the 3.0 release so a lot of the documentation out there seems to be out of date. The previously mentioned thread is the most current I could find. Appreciate help in what I’m doing wrong. Thanks!

    <?php
    /*
    Code to remove hidden woocommerce products from being displayed in a site search
    */
    'tax_query' => array(
                      array(
                            'taxonomy' => 'product_visibility',
                            'field'    => 'name',
                            'terms'    => 'exclude-from-catalog',
                            'operator' => 'NOT IN',
    
                      )
                  ) 

    Here is my system status page:
    ‘`
    ### WordPress Environment ###

    Home URL: https://staging.carsonscookiefix.flywheelsites.com
    Site URL: https://staging.carsonscookiefix.flywheelsites.com
    WC Version: 3.2.1
    Log Directory Writable: ?
    WP Version: 4.8.2
    WP Multisite: –
    WP Memory Limit: 256 MB
    WP Debug Mode: –
    WP Cron: ?
    Language: en_US

    ### Server Environment ###

    Server Info: Flywheel/4.1.0
    PHP Version: 5.6.31-4+ubuntu16.04.1+deb.sury.org+4
    PHP Post Max Size: 300 MB
    PHP Time Limit: 180s
    PHP Max Input Vars: 4000
    cURL Version: 7.47.0
    OpenSSL/1.0.2g

    SUHOSIN Installed: –
    MySQL Version: 5.6.32
    Max Upload Size: 300 MB
    Default Timezone is UTC: ?
    fsockopen/cURL: ?
    SoapClient: ?
    DOMDocument: ?
    GZip: ?
    Multibyte String: ?
    Remote Post: ?
    Remote Get: ?

    ### Database ###

    WC Database Version: 3.2.1
    WC Database Prefix: wp_ih4971isx6_
    MaxMind GeoIP Database: ?
    Total Database Size: 18.37MB
    Database Data Size: 13.83MB
    Database Index Size: 4.54MB
    wp_ih4971isx6_woocommerce_sessions: Data: 0.20MB + Index: 0.02MB
    wp_ih4971isx6_woocommerce_api_keys: Data: 0.02MB + Index: 0.03MB
    wp_ih4971isx6_woocommerce_attribute_taxonomies: Data: 0.02MB + Index: 0.02MB
    wp_ih4971isx6_woocommerce_downloadable_product_permissions: Data: 0.02MB + Index: 0.05MB
    wp_ih4971isx6_woocommerce_order_items: Data: 0.08MB + Index: 0.02MB
    wp_ih4971isx6_woocommerce_order_itemmeta: Data: 1.52MB + Index: 0.48MB
    wp_ih4971isx6_woocommerce_tax_rates: Data: 0.02MB + Index: 0.06MB
    wp_ih4971isx6_woocommerce_tax_rate_locations: Data: 0.02MB + Index: 0.05MB
    wp_ih4971isx6_woocommerce_shipping_zones: Data: 0.02MB + Index: 0.00MB
    wp_ih4971isx6_woocommerce_shipping_zone_locations: Data: 0.02MB + Index: 0.05MB
    wp_ih4971isx6_woocommerce_shipping_zone_methods: Data: 0.02MB + Index: 0.00MB
    wp_ih4971isx6_woocommerce_payment_tokens: Data: 0.02MB + Index: 0.02MB
    wp_ih4971isx6_woocommerce_payment_tokenmeta: Data: 0.02MB + Index: 0.03MB
    wp_ih4971isx6_woocommerce_log: Data: 0.02MB + Index: 0.02MB
    wp_ih4971isx6_commentmeta: Data: 0.02MB + Index: 0.03MB
    wp_ih4971isx6_comments: Data: 0.13MB + Index: 0.09MB
    wp_ih4971isx6_easy_pie_contacts: Data: 0.00MB + Index: 0.00MB
    wp_ih4971isx6_easy_pie_cs_entities: Data: 0.00MB + Index: 0.00MB
    wp_ih4971isx6_easy_pie_cs_subscribers: Data: 0.00MB + Index: 0.00MB
    wp_ih4971isx6_easy_pie_emails: Data: 0.00MB + Index: 0.00MB
    wp_ih4971isx6_gglcptch_whitelist: Data: 0.02MB + Index: 0.02MB
    wp_ih4971isx6_jckwds: Data: 0.00MB + Index: 0.00MB
    wp_ih4971isx6_links: Data: 0.02MB + Index: 0.02MB
    wp_ih4971isx6_options: Data: 4.30MB + Index: 0.08MB
    wp_ih4971isx6_postmeta: Data: 4.52MB + Index: 3.03MB
    wp_ih4971isx6_posts: Data: 2.52MB + Index: 0.23MB
    wp_ih4971isx6_smush_dir_images: Data: 0.00MB + Index: 0.00MB
    wp_ih4971isx6_termmeta: Data: 0.02MB + Index: 0.03MB
    wp_ih4971isx6_terms: Data: 0.02MB + Index: 0.03MB
    wp_ih4971isx6_term_relationships: Data: 0.02MB + Index: 0.02MB
    wp_ih4971isx6_term_taxonomy: Data: 0.02MB + Index: 0.03MB
    wp_ih4971isx6_usermeta: Data: 0.08MB + Index: 0.03MB
    wp_ih4971isx6_users: Data: 0.02MB + Index: 0.05MB
    wp_ih4971isx6_wcpdf_invoice_number: Data: 0.02MB + Index: 0.00MB
    wp_ih4971isx6_wpml_mails: Data: 0.08MB + Index: 0.00MB
    wp_ih4971isx6_wp_topbar_data: Data: 0.00MB + Index: 0.00MB

    ### Post Type Counts ###

    attachment: 322
    custom_css: 1
    customize_changeset: 8
    mc4wp-form: 2
    nav_menu_item: 23
    option-tree: 1
    page: 12
    popup: 1
    popup_theme: 6
    post: 11
    product: 85
    product_variation: 158
    revision: 240
    shop_coupon: 3
    shop_order: 94
    shop_order_refund: 13
    tm_global_cp: 6
    vtmam-rule: 1
    wpcf7_contact_form: 1
    wpephpcompat_jobs: 18

    ### Security ###

    Secure connection (HTTPS): ?Your store is not using HTTPS. Learn more about HTTPS and SSL Certificates.
    Hide errors from visitors: ?

    ### Active Plugins (25) ###

    Addons for Visual Composer: by Visual Composer Addons – 1.6.1
    All-in-One WP Migration Unlimited Extension: by ServMask – 2.10
    All-in-One WP Migration: by ServMask – 6.58
    Contact Form 7: by Takayuki Miyoshi – 4.9
    WooCommerce Continue Shopping: by HappyKite – 1.2 – Not tested with the active version of WooCommerce
    cookiefix-restrict-sameday: by Sixto Santos – 1.0
    Easy Media Download: by naa986 – 1.1.2
    Envato Market: by Derek Herman – 1.0.0-RC2
    WPBakery Page Builder: by Michael M – WPBakery.com – 5.4.2
    MailChimp for WordPress: by ibericode – 4.1.9
    Order Delivery Date Pro for WooCommerce: by Tyche Softwares – 7.2 – Not tested with the active version of WooCommerce
    Lazy Load by WP Rocket: by WP Media – 1.4.3
    Sidekick: by Sidekick.pro – 2.6.8
    Simple 301 Redirects: by Scott Nellé – 1.07
    Compress JPEG & PNG images: by TinyPNG – 2.2.6
    WooCommerce Weight Based Shipping: by weightbasedshipping.com – 5.1.4 – Not tested with the active version of WooCommerce
    WooCommerce Checkout Manager: by Visser Labs – 4.1.6 – Not tested with the active version of WooCommerce
    WooCommerce Min/Max Quantities: by WooCommerce – 2.3.18 – Not tested with the active version of WooCommerce
    WooCommerce Mix and Match: by WooThemes – 1.2.5 – Not tested with the active version of WooCommerce
    WooCommerce PDF Invoices & Packing Slips: by Ewout Fernhout – 2.0.13 – Not tested with the active version of WooCommerce
    WooCommerce Print Orders: by David Anderson – 2.7.5
    WooCommerce Product Add-ons: by WooCommerce – 2.9.0 – Not tested with the active version of WooCommerce
    WooCommerce Square: by WooCommerce – 1.0.22 – Not tested with the active version of WooCommerce
    WooCommerce TM Extra Product Options: by themecomplete – 4.6.3 – Not tested with the active version of WooCommerce
    WooCommerce: by Automattic – 3.2.1

    ### Settings ###

    API Enabled: ?
    Force SSL: ?
    Currency: USD ($)
    Currency Position: left
    Thousand Separator: ,
    Decimal Separator: .
    Number of Decimals: 2
    Taxonomies: Product Types: composite (composite)
    external (external)
    grouped (grouped)
    mix-and-match (mix-and-match)
    simple (simple)
    variable (variable)

    Taxonomies: Product Visibility: exclude-from-catalog (exclude-from-catalog)
    exclude-from-search (exclude-from-search)
    featured (featured)
    outofstock (outofstock)
    rated-1 (rated-1)
    rated-2 (rated-2)
    rated-3 (rated-3)
    rated-4 (rated-4)
    rated-5 (rated-5)

    ### WC Pages ###

    Shop base: #6 – /shop/
    Cart: #7 – /cart/
    Checkout: #8 – /checkout/
    My account: #9 – /my-account/
    Terms and conditions: ? Page not set

    ### Theme ###

    Name: The Voux Child Theme
    Version: 1.0.0
    Author URL:
    Child Theme: ?
    Parent Theme Name: The Voux
    Parent Theme Version: 4.2.0
    Parent Theme Author URL: https://themeforest.net/user/fuelthemes
    WooCommerce Support: ?

    ### Templates ###

    Overrides: thevoux-wp/woocommerce/archive-product.php
    thevoux-wp/woocommerce/cart/cart-empty.php
    thevoux-wp/woocommerce/cart/cart-shipping.php
    thevoux-wp/woocommerce/cart/cart-totals.php
    thevoux-wp/woocommerce/cart/cart.php
    thevoux-wp/woocommerce/cart/proceed-to-checkout-button.php
    thevoux-wp/woocommerce/cart/shipping-calculator.php
    thevoux-wp/woocommerce/checkout/form-checkout.php
    thevoux-wp/woocommerce/checkout/form-coupon.php
    thevoux-wp/woocommerce/checkout/form-login.php
    thevoux-wp/woocommerce/checkout/form-pay.php
    thevoux-wp/woocommerce/checkout/form-shipping.php
    thevoux-wp/woocommerce/checkout/payment-method.php
    thevoux-wp/woocommerce/checkout/payment.php
    thevoux-wp/woocommerce/checkout/terms.php
    thevoux-wp/woocommerce/checkout/thankyou.php
    thevoux-wp/woocommerce/content-product.php
    thevoux-wp/woocommerce/content-product_cat.php
    thevoux-wp/woocommerce/content-single-product.php
    thevoux-wp/woocommerce/global/form-login.php
    thevoux-wp/woocommerce/global/quantity-input.php
    thevoux-wp/woocommerce/global/wrapper-end.php
    thevoux-wp/woocommerce/global/wrapper-start.php
    thevoux-wp/woocommerce/loop/loop-end.php
    thevoux-wp/woocommerce/loop/loop-start.php
    thevoux-wp/woocommerce/loop/no-products-found.php
    thevoux-wp/woocommerce/loop/orderby.php
    thevoux-wp/woocommerce/loop/pagination.php
    thevoux-wp/woocommerce/myaccount/form-login.php
    thevoux-wp/woocommerce/myaccount/form-lost-password.php
    thevoux-wp/woocommerce/myaccount/my-account.php
    thevoux-wp/woocommerce/myaccount/my-address.php
    thevoux-wp/woocommerce/myaccount/navigation.php
    thevoux-wp/woocommerce/notices/error.php
    thevoux-wp/woocommerce/notices/notice.php
    thevoux-wp/woocommerce/notices/success.php
    thevoux-wp/woocommerce/order/order-details-customer.php
    thevoux-wp/woocommerce/product-searchform.php
    thevoux-wp/woocommerce/single-product/add-to-cart/variable.php
    thevoux-wp/woocommerce/single-product/product-image.php
    thevoux-wp/woocommerce/single-product/product-thumbnails.php
    thevoux-wp/woocommerce/single-product/rating.php
    thevoux-wp/woocommerce/single-product/tabs/additional-information.php
    thevoux-wp/woocommerce/single-product/tabs/description.php
    thevoux-wp/woocommerce/single-product/tabs/tabs.php
    thevoux-wp/woocommerce/single-product-reviews.php
    thevoux-wp/woocommerce/single-product.php

    `

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

  • The topic ‘Hidden woocommerce products still showing up in search results’ is closed to new replies.