Viewing 11 replies - 16 through 26 (of 26 total)
  • Although what Julian says is true – hiding elements using CSS does hide them visually – I would not recommend taking that approach in most instances.

    Making something not visible still involves creating it in the first place and delivering it to the browser. That still involves time and database queries, also transfer bytes. It is also still there in the page, so may still get indexed (you may or may not want that).

    In my case, generated the related items was adding over a second to each page generation. It really had to be stopped at source.

    — Jason

    Popovski – you may be better starting a new thread. It sound like you are looking for a text-formatted product listing.

    Judge is correct in saying:

    Making something not visible still involves creating it in the first place and delivering it to the browser. That still involves time and database queries, also transfer bytes.

    His approach is good if you have thousands of products, like he does.

    If you don’t though… the easiest way might be a twist on Julian’s method.

    Another way to remove the related products from the bottom of a product page is by adding the following to your style.css:

    .related.products { display: none; }

    If you are going to use Julian’s approach, don’t modify the style.css file. modify the custom.css file, found in the same folder. There is also a place for that in the theme’s settings on the dashboard.

    remember to FTP in and backup that file before a template update. Then replace after the update. Otherwise you will lose the changes.

    The best way to do this is to *not* modify core files as stated above.

    Rather, add this to your functions.php file:

    function woocommerce_remove_related_products(){
        remove_action( 'woocommerce_after_single_product_summary', 'woocommerce_output_related_products', 20);
    }
    add_action('woocommerce_after_single_product_summary', 'woocommerce_remove_related_products');

    Using this method, you will not lose any modifications when upgrading Woocommerce.

    Note also when brian420 says “your functions.php” he really does mean your functions.php and not the one you will find in any third-party theme, otherwise even that will be lost when the theme is updated.

    You will need to create a child theme of your own (which is very simple, and can inherit everything from its third-party parent theme) and modify that.

    Of course, you could be using your own custom theme already, but I strongly suspect you are not, as there is a lot of fluff that goes into a WooCommerce theme to make things work smoothly.

    @judgej

    If I’m not editing the theme’s functions.php file, what do you mean by “your” functions.php?

    Yes, you edit the theme’s functions.php, but ideally it is not a thirty-party theme that you will be upgrading from time-to-time. Instead, you can create your own child theme and you can do what you like with functions.php in there, without it being overwritten when the third-party theme is upgraded.

    However, make sure your child theme does not have the same name as any theme on the WordPress.com site, otherwise a careless update in the WordPress admin pages can overwrite your child theme from something from WordPress.com

    Another option if you don’t want to use a child theme is to use a functions plugin. The advantages of doing it this way is that you can change your theme without losing your customizations.

    If you bought Theme A and use it with WooCommerce and later decide you want to use Theme B, you don’t have to create a new child them since the custom plugin is still active and loading the content of /wp-content/plugins/functions.php (though it has occurred to me that perhaps /wp-content/themes/functions.php would be a better fit)

    You can see an example on my site here https://justin.ag/technology/wordpress-plugins/wordpress-plugin-custom-functions-php/

    @brian
    Thanks for posting the related items cart filter.
    Very much appreciated.

    I too am trying to remove the Related Products section, due to its rather arbitrary selection of “related” items.

    I am using Woocommerce with the Merchant theme from Woo on WordPress and all files and plugins are up to date.

    I added Brian’s code snippet to my functions.php file but the Related Items have failed to do a vanishing trick.

    Example URL: https://www.sandayspinners.co.uk/product/knitpro-symfonie-straight-needles-35cm/

    Can anybody help, please?

    Alternatively – I’d be happy to keep Related Products if I had control over it. Am I missing a trick here? Because I cannot find a setting for the number of items to output and/or the categories to include. (Nor do I understand why this section exists, when there is the better Up Sell and Cross sell mechanism.) Any experienced users know how to do this?

    TIA

    My problem is solved. I eventually navigated to Woo site to find thispage
    https://wcdocs.woothemes.com/snippets/remove-related-posts-output/

    the code snippet there does the job beautifully

    /*
    * wc_remove_related_products
    *
    * Clear the query arguments for related products so none show.
    * Add this code to your theme functions.php file.
    */
    function wc_remove_related_products( $args ) {
    return array();
    }
    add_filter('woocommerce_related_products_args','wc_remove_related_products', 10);
Viewing 11 replies - 16 through 26 (of 26 total)
  • The topic ‘WooCommerce: remove related products info’ is closed to new replies.