Disable Product Pages in WooCommerce

Add the following code to your functions.php file to disable users from accessing product pages within WooCommerce:

/* Remove Links to Access Product Pages */
remove_action( 'woocommerce_before_shop_loop_item', 'woocommerce_template_loop_product_link_open', 10 );
remove_action( 'woocommerce_after_shop_loop_item', 'woocommerce_template_loop_product_link_close', 5 );

/* Prevent Users from Accessing Product Pages by Displaying the 404 Page */
function prevent_access_to_product_page(){
    global $post;
    if ( is_product() ) {
        global $wp_query; $wp_query->set_404();
        status_header(404);
    }
}

Other Helpful Articles

Content Writing Tips

If you are writing content for your website, it can be at times challenging. There’s a specific format that you should write content for your site. If you want to write some particular information on your website that pertains to your businesses or service, there are some ways to do

Read More »

What is Webmail?

What is webmail? Webmail is usually a free cloud-based email service that is set up on your hosting. You can use webmail by having a professional-looking email address such as, “[email protected]” and it’s usually at no additional cost. You can also have a professional-looking email with an email client such

Read More »

What Do You Need Done?:

(Please check all that apply)

Tell Us About You

Almost Done!

Let's Get Some Info

Let's Get Some Info

Let's Get Some Info

Let's Get Some Info