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

Smart Web Creative - Quick Resources: Date and Time in PHP

Quick Resources: Date and Time in PHP

If you want to display the date and time in PHP, it can be somewhat confusing what letters to use to bring in those elements. Below is a list of all the PHP date and time options that you can use on your site: To utilize these options in PHP,

Read More »

Online Generator for Writing a Privacy Policy

Many websites need a privacy policy page. WordPress actually has a pre-built privacy policy page that users can edit. However, editing what they give you can be a little overwhelming. Furthermore, depending on your business, it may be better to use a lawyer to write up a more detailed privacy

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