Disable WooCommerce Product Title & Image Links Without a Plugin (PHP + CSS)
If you want to prevent visitors from opening single product pages by clicking the product title or product image on your WooCommerce shop page, you can do it easily with a small PHP snippet. This method requires no additional plugin and works with most WooCommerce themes, including Elementor WooCommerce Product Grid.
This solution is especially useful for:
Wholesale WooCommerce stores
B2B websites
Catalog mode stores
Login-required shops
Websites that hide prices until users log in
What This Code Does
Disables clicks on the product image.
Disables clicks on the product title.
Keeps the Add to Cart button fully functional.
Applies only to visitors who are not logged in.
Works on WooCommerce Shop, Category, Tag, and Product Archive pages.
PHP Code
add_action('wp_head', function () {
if ( ! is_user_logged_in() ) {
?>
<style>
.woocommerce ul.products li.product a:not(.button){
pointer-events:none;
cursor:default;
text-decoration:none;
color:inherit;
}
.woocommerce ul.products li.product a.button{
pointer-events:auto;
}
</style>
<?php
}
});
How to Add the Code
Log in to your WordPress dashboard.
Install and activate the Code Snippets plugin (recommended), or add the code to your child theme's
functions.phpfile.Paste the PHP code above.
Save and activate the snippet.
Visit your WooCommerce shop page while logged out to test it.
How It Works
The PHP snippet checks whether the visitor is logged in.
If the visitor is not logged in, CSS is automatically added to the page.
The CSS disables clicking on product images and product titles using
pointer-events: none.The Add to Cart button continues to work because it is excluded from the rule.
This provides a simple way to restrict access to product pages for guest visitors while still allowing them to browse your catalog.
Benefits
No plugin required
Lightweight solution
Easy to install
Works with WooCommerce
Compatible with Elementor WooCommerce Product Grid
Improves control over guest users
Perfect for wholesale and B2B stores
Conclusion
Using this simple PHP snippet, you can quickly disable product title and image links for guest users while keeping your WooCommerce store clean and functional. It's a practical solution for stores that require users to log in before viewing product details or prices.
If you found this tutorial helpful, share it with other WordPress users and check back for more WooCommerce, Elementor, CSS, and WordPress customization tutorials.


