Title: [yith_compare_button] shortcode not rendering
Last modified: July 30, 2025

---

# [yith_compare_button] shortcode not rendering

 *  Resolved [ktatkehorne](https://wordpress.org/support/users/ktatkehorne/)
 * (@ktatkehorne)
 * [10 months, 2 weeks ago](https://wordpress.org/support/topic/yith_compare_button-shortcode-not-rendering/)
 * The above is a staging site as the upgrade of free version YITH WooCommerce Compare
   plugin from 2.48.0 to 3.2.0 has broken the compare button. [yith_compare_button]
   displays instead of the compare button (compare live site: [https://practicalbathing.co.uk/product-category/walk-in-baths/](https://practicalbathing.co.uk/product-category/walk-in-baths/))
   
   I have taken on the site recently and asked to update WP and plugins. The site
   has a bespoke theme which was written at least 5 years ago.In the theme inc folder
   there is a file called extras.php with
 * function practical_compare_and_wishlist_tab( ) {
 *     ```wp-block-code
       ob_start();
       //$yith_compare = new YITH_Woocompare_Frontend();
       //add_shortcode( 'yith_compare_button', array( $yith_compare , 'compare_button_sc' ) );
       echo '
       <ul>
       <li>'.do_shortcode('[yith_compare_button]').'</li>
       <li>'.do_shortcode('[yith_wcwl_add_to_wishlist]').'</li>
   
       </ul>';
       $content=ob_get_contents();
       ob_end_clean();
       echo $content;
       ```
   
 * };
 * add_action( ‘woocommerce_after_add_to_cart_button’, ‘practical_compare_and_wishlist_tab’,
   100, 0 );
 * BTW as a test I ativated WP 2025 theme and the compare button works so I know
   this is theme related.
   Do you have any clues as to what has changed between version
   2.48.0 and 3.2.0 that would cause the shortcode not to work?This is the error
   message in the error log:E_USER_NOTICE: Function do_shortcode_tag was called 
   incorrectly. Attempting to parse a shortcode without a valid callback: yith_compare_button
   Please see Debugging in WordPress for more information. (This message was added
   in version 4.3.0.) in /mnt/BLOCKSTORAGE/home/1101307.cloudwaysapps.com/gghcuutkcq/
   public_html/wp-includes/functions.php on line 6121
 * The page I need help with: _[[log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fwordpress.org%2Fsupport%2Ftopic%2Fyith_compare_button-shortcode-not-rendering%2F%3Foutput_format%3Dmd&locale=en_US)
   to see the link]_

Viewing 8 replies - 1 through 8 (of 8 total)

 *  [Juan Coronel](https://wordpress.org/support/users/juaancmendez/)
 * (@juaancmendez)
 * [10 months, 1 week ago](https://wordpress.org/support/topic/yith_compare_button-shortcode-not-rendering/#post-18580084)
 * Hello there,
   thanks for contacting us!
 * Maybe the problem is due to the class name, since the correct one is:
 *     ```wp-block-code
       YITH_WooCompare_Frontend();
       ```
   
 * Additionally, you can use the following code to call the instance of the class:
 *     ```wp-block-code
       YITH_WooCompare_Frontend::instance();
       ```
   
 * Could you check it, please?
 * Best regards.
 *  Thread Starter [ktatkehorne](https://wordpress.org/support/users/ktatkehorne/)
 * (@ktatkehorne)
 * [10 months, 1 week ago](https://wordpress.org/support/topic/yith_compare_button-shortcode-not-rendering/#post-18580194)
 * Hi
 * Thanks for reaching out.
   I’ve just noted the code I added above looks like 2 
   lines are commented out but they should have read:Checking what you have asked
   me to check, they look the same:
 * function practical_compare_and_wishlist_tab( ) {
 *     ```wp-block-code
       ob_start();$yith_compare = new YITH_Woocompare_Frontend();add_shortcode( 'yith_compare_button', array( $yith_compare , 'compare_button_sc' ) );echo '<ul><li>'.do_shortcode('[yith_compare_button]').'</li><li>'.do_shortcode('[yith_wcwl_add_to_wishlist]').'</li></ul>';$content=ob_get_contents();ob_end_clean();echo $content;
       ```
   
 * };
 * add_action( ‘woocommerce_after_add_to_cart_button’, ‘practical_compare_and_wishlist_tab’,
   100, 0 );
 *  [Juan Coronel](https://wordpress.org/support/users/juaancmendez/)
 * (@juaancmendez)
 * [10 months, 1 week ago](https://wordpress.org/support/topic/yith_compare_button-shortcode-not-rendering/#post-18581901)
 * Hi there,
 * Please replace your code with this new one:
 *     ```wp-block-code
       function practical_compare_and_wishlist_tab() {    ob_start();    echo '<ul>            <li>' . do_shortcode('[yith_compare_button]') . '</li>            <li>' . do_shortcode('[yith_wcwl_add_to_wishlist]') . '</li>          </ul>';    $content = ob_get_contents();    ob_end_clean();    echo $content;};add_action('woocommerce_after_add_to_cart_button', 'practical_compare_and_wishlist_tab', 100, 0);
       ```
   
 * Could you check it, please?
 * Best regards.
 *  Thread Starter [ktatkehorne](https://wordpress.org/support/users/ktatkehorne/)
 * (@ktatkehorne)
 * [10 months, 1 week ago](https://wordpress.org/support/topic/yith_compare_button-shortcode-not-rendering/#post-18584799)
 * Hi 
   Thank you – so that now works…It is this one that doesn’t still:
 * function woocommerce_after_shop_loop_item(){
 *     ```wp-block-code
        $yith_compare = new YITH_WooCompare_Frontend();
        add_shortcode( 'yith_compare_button', array( $yith_compare , 'compare_button_sc' ) );
        echo '
        <ul>
        <li>'.do_shortcode('[yith_compare_button]').'</li>
        <li>'.do_shortcode('[yith_wcwl_add_to_wishlist]').'</li>
   
        </ul>';
       ```
   
 * }
   add_action(‘woocommerce_after_shop_loop_item’,’woocommerce_after_shop_loop_item’);
 *  [Juan Coronel](https://wordpress.org/support/users/juaancmendez/)
 * (@juaancmendez)
 * [10 months, 1 week ago](https://wordpress.org/support/topic/yith_compare_button-shortcode-not-rendering/#post-18586104)
 * Hi there,
 * Simply keep the following code to display the button on the shop and single product
   page:
 *     ```wp-block-code
       if ( ! function_exists( 'practical_compare_and_wishlist_tab' ) ) {    function practical_compare_and_wishlist_tab() {        ob_start();        echo '<ul>                <li>' . do_shortcode('[yith_compare_button]') . '</li>                <li>' . do_shortcode('[yith_wcwl_add_to_wishlist]') . '</li>            </ul>';        $content = ob_get_contents();        ob_end_clean();        echo $content;    };    add_action('woocommerce_after_add_to_cart_button', 'practical_compare_and_wishlist_tab', 100 );    add_action('woocommerce_after_shop_loop_item', 'practical_compare_and_wishlist_tab', 100 );}
       ```
   
 * Could you check it, please?
 * Best regards.
 *  Thread Starter [ktatkehorne](https://wordpress.org/support/users/ktatkehorne/)
 * (@ktatkehorne)
 * [10 months, 1 week ago](https://wordpress.org/support/topic/yith_compare_button-shortcode-not-rendering/#post-18588215)
 * Hi
   Thank you for your help so far! So I tried your last bit of code and that 
   didn’t quite work as it lost it’s buttons. I have managed to add the code into
   function woocommerce_after_shop_loop_item(){} and everything is working fine 
   now except that I have noticed that now this plugin is updated it adds the compare
   link twice as a tiny white text link. I restored the site so that my extras.php
   was back to it’s original version before I corrected the code and I notice that
   the compare link is added twice in that page too. The second “Compare” is tiny
   and white but still just visible. When I inspect the page the same link is there
   twice.
 * ![](https://wordpress.org/3d69e515-2c4c-483f-a1a1-d8795bcb1b25)
    -  This reply was modified 10 months, 1 week ago by [ktatkehorne](https://wordpress.org/support/users/ktatkehorne/).
 *  [Juan Coronel](https://wordpress.org/support/users/juaancmendez/)
 * (@juaancmendez)
 * [10 months ago](https://wordpress.org/support/topic/yith_compare_button-shortcode-not-rendering/#post-18589968)
 * Hello there,
 * Maybe that’s because you need to enable the following option if you want to display
   the button with the shortcode on the shop page:
 *     ```wp-block-code
       General Settings > "Compare" button > Show compare in: > Product Pages
       ```
   
 * Currently, everything looks fine on your staging, so if you still need assistance,
   I’ll have to review the issue from your site to see what’s going on.
 * Please let me know.
 * Best regards.
 *  Thread Starter [ktatkehorne](https://wordpress.org/support/users/ktatkehorne/)
 * (@ktatkehorne)
 * [10 months ago](https://wordpress.org/support/topic/yith_compare_button-shortcode-not-rendering/#post-18590791)
 * Thank you so much. That has worked! The setting was on Shop Pages. It tried change
   to “Both” and that was still not right. Now it is set to just “Product Pages”
   and all is working fine.
 * Thank you again.

Viewing 8 replies - 1 through 8 (of 8 total)

The topic ‘[yith_compare_button] shortcode not rendering’ is closed to new replies.

 * ![](https://ps.w.org/yith-woocommerce-compare/assets/icon.svg?rev=3042935)
 * [YITH WooCommerce Compare](https://wordpress.org/plugins/yith-woocommerce-compare/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/yith-woocommerce-compare/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/yith-woocommerce-compare/)
 * [Active Topics](https://wordpress.org/support/plugin/yith-woocommerce-compare/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/yith-woocommerce-compare/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/yith-woocommerce-compare/reviews/)

 * 8 replies
 * 2 participants
 * Last reply from: [ktatkehorne](https://wordpress.org/support/users/ktatkehorne/)
 * Last activity: [10 months ago](https://wordpress.org/support/topic/yith_compare_button-shortcode-not-rendering/#post-18590791)
 * Status: resolved