How to remove classes added to Woocommerce li.product?












0














Woocommerce adds the assigned product categories and attributes as custom classes to li.product



<li class="post-120 product type-product status-publish has-post-thumbnail 
category1 category2 category3 category4 pa_one pa_two...">


We have assigned quite a lot of categories to each product and it slows down the site. Is there a way to remove those additional classes?










share|improve this question
























  • and how does several classes slow down the site? did you make any perfomance tests?
    – Samvel Aleqsanyan
    Jan 31 '18 at 16:33










  • @SamvelAleqsanyan yes, it sounds weird but we are talking about hundreds of classes from assigned categories (hierarchies) and attributes added to each product. I changed <li <?php //post_class(); ?> class="product"> in content-product.php. That did the trick and immediately reduced loading times by about 5 seconds.
    – gerryb
    Feb 1 '18 at 13:39
















0














Woocommerce adds the assigned product categories and attributes as custom classes to li.product



<li class="post-120 product type-product status-publish has-post-thumbnail 
category1 category2 category3 category4 pa_one pa_two...">


We have assigned quite a lot of categories to each product and it slows down the site. Is there a way to remove those additional classes?










share|improve this question
























  • and how does several classes slow down the site? did you make any perfomance tests?
    – Samvel Aleqsanyan
    Jan 31 '18 at 16:33










  • @SamvelAleqsanyan yes, it sounds weird but we are talking about hundreds of classes from assigned categories (hierarchies) and attributes added to each product. I changed <li <?php //post_class(); ?> class="product"> in content-product.php. That did the trick and immediately reduced loading times by about 5 seconds.
    – gerryb
    Feb 1 '18 at 13:39














0












0








0







Woocommerce adds the assigned product categories and attributes as custom classes to li.product



<li class="post-120 product type-product status-publish has-post-thumbnail 
category1 category2 category3 category4 pa_one pa_two...">


We have assigned quite a lot of categories to each product and it slows down the site. Is there a way to remove those additional classes?










share|improve this question















Woocommerce adds the assigned product categories and attributes as custom classes to li.product



<li class="post-120 product type-product status-publish has-post-thumbnail 
category1 category2 category3 category4 pa_one pa_two...">


We have assigned quite a lot of categories to each product and it slows down the site. Is there a way to remove those additional classes?







php wordpress woocommerce taxonomy-terms






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Feb 1 '18 at 13:42

























asked Jan 31 '18 at 16:05









gerryb

33




33












  • and how does several classes slow down the site? did you make any perfomance tests?
    – Samvel Aleqsanyan
    Jan 31 '18 at 16:33










  • @SamvelAleqsanyan yes, it sounds weird but we are talking about hundreds of classes from assigned categories (hierarchies) and attributes added to each product. I changed <li <?php //post_class(); ?> class="product"> in content-product.php. That did the trick and immediately reduced loading times by about 5 seconds.
    – gerryb
    Feb 1 '18 at 13:39


















  • and how does several classes slow down the site? did you make any perfomance tests?
    – Samvel Aleqsanyan
    Jan 31 '18 at 16:33










  • @SamvelAleqsanyan yes, it sounds weird but we are talking about hundreds of classes from assigned categories (hierarchies) and attributes added to each product. I changed <li <?php //post_class(); ?> class="product"> in content-product.php. That did the trick and immediately reduced loading times by about 5 seconds.
    – gerryb
    Feb 1 '18 at 13:39
















and how does several classes slow down the site? did you make any perfomance tests?
– Samvel Aleqsanyan
Jan 31 '18 at 16:33




and how does several classes slow down the site? did you make any perfomance tests?
– Samvel Aleqsanyan
Jan 31 '18 at 16:33












@SamvelAleqsanyan yes, it sounds weird but we are talking about hundreds of classes from assigned categories (hierarchies) and attributes added to each product. I changed <li <?php //post_class(); ?> class="product"> in content-product.php. That did the trick and immediately reduced loading times by about 5 seconds.
– gerryb
Feb 1 '18 at 13:39




@SamvelAleqsanyan yes, it sounds weird but we are talking about hundreds of classes from assigned categories (hierarchies) and attributes added to each product. I changed <li <?php //post_class(); ?> class="product"> in content-product.php. That did the trick and immediately reduced loading times by about 5 seconds.
– gerryb
Feb 1 '18 at 13:39












2 Answers
2






active

oldest

votes


















0














If you know php, You can edit the woocoommerce php template file to remove those additional classes.
If you opened the file, there is a php variable to be added additional classes and it is a array.






share|improve this answer





















  • You should provide the name of (and where to find) the file in question.
    – CFP Support
    Jan 31 '18 at 17:30










  • content-product.php
    – Jin Huang
    Jan 31 '18 at 17:45










  • @JinHuang saw your comment too late but you are right, content-product.php is where we changed this line <li <?php //post_class(); ?> class="product"> and that solved it.
    – gerryb
    Feb 1 '18 at 13:41










  • Ping me anytime if you need me :)
    – Jin Huang
    Feb 1 '18 at 17:53



















0














I would suggest applying a filter to the post_class function instead of editing the template as woocommerce updates these regularly and can be a pain to keep on top of them. To do this you could check to see if you in the product loop or if a product exists to also remove from the product page like this :



add_filter( 'post_class', function($classes){
$product = wc_get_product();
return ($product) ? array('product' 'or-any-class-you-want') : $classes; } , 9999 );





share|improve this answer





















    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f48546487%2fhow-to-remove-classes-added-to-woocommerce-li-product%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    If you know php, You can edit the woocoommerce php template file to remove those additional classes.
    If you opened the file, there is a php variable to be added additional classes and it is a array.






    share|improve this answer





















    • You should provide the name of (and where to find) the file in question.
      – CFP Support
      Jan 31 '18 at 17:30










    • content-product.php
      – Jin Huang
      Jan 31 '18 at 17:45










    • @JinHuang saw your comment too late but you are right, content-product.php is where we changed this line <li <?php //post_class(); ?> class="product"> and that solved it.
      – gerryb
      Feb 1 '18 at 13:41










    • Ping me anytime if you need me :)
      – Jin Huang
      Feb 1 '18 at 17:53
















    0














    If you know php, You can edit the woocoommerce php template file to remove those additional classes.
    If you opened the file, there is a php variable to be added additional classes and it is a array.






    share|improve this answer





















    • You should provide the name of (and where to find) the file in question.
      – CFP Support
      Jan 31 '18 at 17:30










    • content-product.php
      – Jin Huang
      Jan 31 '18 at 17:45










    • @JinHuang saw your comment too late but you are right, content-product.php is where we changed this line <li <?php //post_class(); ?> class="product"> and that solved it.
      – gerryb
      Feb 1 '18 at 13:41










    • Ping me anytime if you need me :)
      – Jin Huang
      Feb 1 '18 at 17:53














    0












    0








    0






    If you know php, You can edit the woocoommerce php template file to remove those additional classes.
    If you opened the file, there is a php variable to be added additional classes and it is a array.






    share|improve this answer












    If you know php, You can edit the woocoommerce php template file to remove those additional classes.
    If you opened the file, there is a php variable to be added additional classes and it is a array.







    share|improve this answer












    share|improve this answer



    share|improve this answer










    answered Jan 31 '18 at 17:25









    Jin Huang

    161




    161












    • You should provide the name of (and where to find) the file in question.
      – CFP Support
      Jan 31 '18 at 17:30










    • content-product.php
      – Jin Huang
      Jan 31 '18 at 17:45










    • @JinHuang saw your comment too late but you are right, content-product.php is where we changed this line <li <?php //post_class(); ?> class="product"> and that solved it.
      – gerryb
      Feb 1 '18 at 13:41










    • Ping me anytime if you need me :)
      – Jin Huang
      Feb 1 '18 at 17:53


















    • You should provide the name of (and where to find) the file in question.
      – CFP Support
      Jan 31 '18 at 17:30










    • content-product.php
      – Jin Huang
      Jan 31 '18 at 17:45










    • @JinHuang saw your comment too late but you are right, content-product.php is where we changed this line <li <?php //post_class(); ?> class="product"> and that solved it.
      – gerryb
      Feb 1 '18 at 13:41










    • Ping me anytime if you need me :)
      – Jin Huang
      Feb 1 '18 at 17:53
















    You should provide the name of (and where to find) the file in question.
    – CFP Support
    Jan 31 '18 at 17:30




    You should provide the name of (and where to find) the file in question.
    – CFP Support
    Jan 31 '18 at 17:30












    content-product.php
    – Jin Huang
    Jan 31 '18 at 17:45




    content-product.php
    – Jin Huang
    Jan 31 '18 at 17:45












    @JinHuang saw your comment too late but you are right, content-product.php is where we changed this line <li <?php //post_class(); ?> class="product"> and that solved it.
    – gerryb
    Feb 1 '18 at 13:41




    @JinHuang saw your comment too late but you are right, content-product.php is where we changed this line <li <?php //post_class(); ?> class="product"> and that solved it.
    – gerryb
    Feb 1 '18 at 13:41












    Ping me anytime if you need me :)
    – Jin Huang
    Feb 1 '18 at 17:53




    Ping me anytime if you need me :)
    – Jin Huang
    Feb 1 '18 at 17:53













    0














    I would suggest applying a filter to the post_class function instead of editing the template as woocommerce updates these regularly and can be a pain to keep on top of them. To do this you could check to see if you in the product loop or if a product exists to also remove from the product page like this :



    add_filter( 'post_class', function($classes){
    $product = wc_get_product();
    return ($product) ? array('product' 'or-any-class-you-want') : $classes; } , 9999 );





    share|improve this answer


























      0














      I would suggest applying a filter to the post_class function instead of editing the template as woocommerce updates these regularly and can be a pain to keep on top of them. To do this you could check to see if you in the product loop or if a product exists to also remove from the product page like this :



      add_filter( 'post_class', function($classes){
      $product = wc_get_product();
      return ($product) ? array('product' 'or-any-class-you-want') : $classes; } , 9999 );





      share|improve this answer
























        0












        0








        0






        I would suggest applying a filter to the post_class function instead of editing the template as woocommerce updates these regularly and can be a pain to keep on top of them. To do this you could check to see if you in the product loop or if a product exists to also remove from the product page like this :



        add_filter( 'post_class', function($classes){
        $product = wc_get_product();
        return ($product) ? array('product' 'or-any-class-you-want') : $classes; } , 9999 );





        share|improve this answer












        I would suggest applying a filter to the post_class function instead of editing the template as woocommerce updates these regularly and can be a pain to keep on top of them. To do this you could check to see if you in the product loop or if a product exists to also remove from the product page like this :



        add_filter( 'post_class', function($classes){
        $product = wc_get_product();
        return ($product) ? array('product' 'or-any-class-you-want') : $classes; } , 9999 );






        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 21 '18 at 13:56









        Katie

        15114




        15114






























            draft saved

            draft discarded




















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.





            Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


            Please pay close attention to the following guidance:


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f48546487%2fhow-to-remove-classes-added-to-woocommerce-li-product%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            404 Error Contact Form 7 ajax form submitting

            How to know if a Active Directory user can login interactively

            Refactoring coordinates for Minecraft Pi buildings written in Python