Need to remove related products from a specific product page? There’s many ways to do this using PHP code or CSS. This solution uses custom fields, either the fields native to WordPress,
or any custom field plugin like ACF.
Tested using the Twenty Twenty default theme for WordPress however will work in any WordPress theme.
There’s 2 steps, (1) The input value and (2) the output ( PHP code ) :
- # Install ACF and import this json file using the Custom Fields > Tools settings which creates the setting you need to remove related products.
- # From the view raw link in the Gist, copy & paste the following PHP code to the end of your child themes functions.php file or custom functionality plugin.
If not using ACF, use this WordPress custom field key and value :
You can then use the button on your Edit Product screen to remove related products on one or more single product pages.
Leave a Reply
You must be logged in to post a comment.