Tagged: x
-
AuthorPosts
-
January 6, 2017 at 11:48 am #1319083
fatheaddrummerParticipantHello Awesome Support Team,
I would like to exclude my product page from autoptimize: https://www.diamond-precision-studio.com/product/trance-dance-cd-mix/
But it doesn’t work. I am using this code to this!
add_filter('autoptimize_filter_noptimize','my_ao_noptimize',10,0); function my_ao_noptimize() { if ((strpos($_SERVER['REQUEST_URI'],'woocommerce')!==false) || if (strpos($_SERVER['REQUEST_URI'],'request-free-mixdown-preview')!==false)) { return true; } else { return false; } }The code works fine on the other page (request-free-mixdown-preview).
I have the feeling that it doesn’t work because the product page is not an actual page?Could you help me out? Thank you so much!
Best, ChristianJanuary 6, 2017 at 8:55 pm #1319726
Rue NelModeratorHello Christian,
Thanks for writing in! Instead of getting the request_uri, you can use the WooCommerce conditional tags (https://docs.woocommerce.com/document/conditional-tags/) so that you can target all the product pages. Please have your code updated and make use of this code:
add_filter('autoptimize_filter_noptimize','my_ao_noptimize',10,0); function my_ao_noptimize() { if ( is_product() ) { return true; } else { return false; } }Hope this helps. Please let us know how it goes.
January 7, 2017 at 9:07 am #1320158
fatheaddrummerParticipantHi there,
Thank you so much for your awesome support!
This is what I added in the code! I also need a single page to be excluded, that’s why I tried to combine them, but unfortunately the product page still is NOT excluded…What have I done wrong?
add_filter('autoptimize_filter_noptimize','my_ao_noptimize',10,0); function my_ao_noptimize() { if ( (strpos($_SERVER['REQUEST_URI'],'request-free-mixdown-preview')!==false) || ( is_product() ){ return true; } else { return false; } }Also I would like to exclude all woocommerce pages…
Thank you so much!
Best, ChristianJanuary 7, 2017 at 10:00 am #1320201
ThaiModeratorHi There,
Please update your code to this:
add_filter('autoptimize_filter_noptimize','my_ao_noptimize',10,0); function my_ao_noptimize() { if ( strpos($_SERVER['REQUEST_URI'],'request-free-mixdown-preview') !== false || is_cart() || is_woocommerce() || is_checkout() || is_account_page() ) { return true; } else { return false; } }Hope it helps 🙂
January 7, 2017 at 10:21 am #1320214
fatheaddrummerParticipantThank you so much!
You’re awesome!!Best, Christian
January 7, 2017 at 10:45 am #1320234
ThaiModeratorIf you need anything else please let us know.
-
AuthorPosts
- <script> jQuery(function($){ $("#no-reply-1319083 .bbp-template-notice, .bbp-no-topic .bbp-template-notice").removeClass('bbp-template-notice'); }); </script>
