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

How To Create an Email Signature in Gmail/G Suite

You may have noticed many businesses and individuals will have email signatures that look professional. If you have Gmail or G Suite, there’s actually a pretty easy way to set one up. To start creating your email signature, sign in to your Gmail account. Over in the top right you’ll

Read More »

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 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

Let's Get Some Info

Let's Get Some Info