Title: Change the Button HTML
Last modified: March 24, 2021

---

# Change the Button HTML

 *  [adam198](https://wordpress.org/support/users/adam198/)
 * (@adam198)
 * [5 years, 2 months ago](https://wordpress.org/support/topic/change-the-button-html/)
 * Hi,
 * I want to change the button HTML but I am struggling with it. I really only want
   to add a title to the button/link tag with the button_text as the value.
 * I understand I can use wooscp_button_html filter but I am not sure what to replace
   it with. If I use the wooscp_shortcode function then edit the output I will get
   undefined variables.
 * Is what I want to do possible?

Viewing 1 replies (of 1 total)

 *  Plugin Author [WPClever](https://wordpress.org/support/users/wpclever/)
 * (@wpclever)
 * [5 years, 1 month ago](https://wordpress.org/support/topic/change-the-button-html/#post-14318206)
 * Hi [@adam198](https://wordpress.org/support/users/adam198/)
 * You can add below snippet to current-theme (or child-theme) / functions.php:
 *     ```
       add_filter( 'wooscp_button_html', 'wooscp_custom_button_html', 99, 2 );
       function wooscp_custom_button_html( $html, $product_id ) {
       	$button_text = get_option( '_wooscp_button_text' );
   
       	if ( empty( $button_text ) ) {
       		$button_text = esc_html__( 'Compare', 'wooscp' );
       	}
   
       	// change the link as you want here
       	return '<a href="#" class="woosc-btn wooscp-btn wooscp-btn-' . esc_attr( $product_id ) . ' ' . get_option( '_wooscp_button_class' ) . '" data-id="' . esc_attr( $product_id ) . '">' . esc_html( $button_text ) . '</a>';
       }
       ```
   

Viewing 1 replies (of 1 total)

The topic ‘Change the Button HTML’ is closed to new replies.

 * ![](https://ps.w.org/woo-smart-compare/assets/icon-128x128.png?rev=1858171)
 * [WPC Smart Compare for WooCommerce](https://wordpress.org/plugins/woo-smart-compare/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/woo-smart-compare/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/woo-smart-compare/)
 * [Active Topics](https://wordpress.org/support/plugin/woo-smart-compare/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/woo-smart-compare/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/woo-smart-compare/reviews/)

 * 1 reply
 * 2 participants
 * Last reply from: [WPClever](https://wordpress.org/support/users/wpclever/)
 * Last activity: [5 years, 1 month ago](https://wordpress.org/support/topic/change-the-button-html/#post-14318206)
 * Status: not resolved