shvsh > /home/1168859.cloudwaysapps.com/rcyqmhwrmv/public_html/docs/wp-content/plugins/ht-knowledge-base/ht-knowledge-base.php
shvsh > /home/1168859.cloudwaysapps.com/rcyqmhwrmv/public_html/docs/wp-content/plugins/ht-knowledge-base/ht-knowledge-base.php
shvsh > /home/1168859.cloudwaysapps.com/rcyqmhwrmv/public_html/docs/wp-content/plugins/ht-knowledge-base/ht-knowledge-base.php

Hide the Addon products on the shop page.

Follow these steps to hide the CPB’s addon products on the shop page.

  1. Download the attached file and override in the mentioned path wp-content/plugins/custom-product-boxes/admin/settings/class-cpb-settings.php
  2. Go to Custom Product Boxes > Settings and Enable Hide add-on’s from shop option and then Enter the password. It will change the status of the product from published to protected.
  3. After overriding the file, add the following code in your function.php of child_theme/main_theme.
 // Filter to hide protected posts
function cpb_exclude_protected($where) {
    global $wpdb;
    return $where .= " AND {$wpdb->posts}.post_password = '' ";
}

// Decide where to display them
function cpb_exclude_protected_action($query) {
    if ( 'product' != $_REQUEST['post_type'] ) {
        add_filter( 'posts_where', 'cpb_exclude_protected' );
    }
}

// Action to queue the filter at the right time
add_action('pre_get_posts', 'cpb_exclude_protected_action');
  • The above code will hide the protected product from the Shop page.

Updated on April 11, 2023
shvsh > /home/1168859.cloudwaysapps.com/rcyqmhwrmv/public_html/docs/wp-content/plugins/ht-knowledge-base/ht-knowledge-base.php
shvsh > /home/1168859.cloudwaysapps.com/rcyqmhwrmv/public_html/docs/wp-content/plugins/ht-knowledge-base/ht-knowledge-base.php
shvsh > /home/1168859.cloudwaysapps.com/rcyqmhwrmv/public_html/docs/wp-content/plugins/ht-knowledge-base/ht-knowledge-base.php

Was this article helpful?

shvsh > /home/1168859.cloudwaysapps.com/rcyqmhwrmv/public_html/docs/wp-content/plugins/ht-knowledge-base/ht-knowledge-base.php
shvsh > /home/1168859.cloudwaysapps.com/rcyqmhwrmv/public_html/docs/wp-content/plugins/ht-knowledge-base/ht-knowledge-base.php

Related Articles