How to Customize the Position and Appearance of Your YITH Wishlist Button
Content
One of the most common challenges when using the YITH WooCommerce Wishlist plugin is getting the 'Add to Wishlist' button to appear exactly where you want it on your product pages. Users often find the button appears in an unexpected location, such as below the 'Add to Cart' button, within payment methods, or not aligned correctly with other elements. This guide will walk you through the most effective methods to reposition and style your wishlist button for a seamless store experience.
Why Does This Happen?
The plugin's default settings and your theme's specific HTML structure are the primary factors. While the plugin offers several built-in positions (like 'After Add to Cart'), these hooks may not align perfectly with your theme's design. This often results in the button appearing in a less-than-ideal spot, requiring manual adjustment.
Common Solutions for Repositioning the Button
1. Using a Custom Code Snippet (PHP)
The most powerful way to move the button is by using a small code snippet in your theme's functions.php file. This method uses JavaScript to find the button and move it to a new location in the Document Object Model (DOM) after the page loads.
Example: Move the button next to the 'Add to Cart' button
if ( ! function_exists( 'yith_wcwl_custom_styles' ) ) {
function yith_wcwl_custom_styles() {
$jquery = 'jQuery( function($) {
let wishlistContainer = $( "body.single-product .summary .yith-wcwl-add-to-wishlist" );
wishlistContainer.insertAfter( ".summary button.single_add_to_cart_button" );
});';
wp_add_inline_script( 'jquery-yith-wcwl', $jquery );
wp_add_inline_script( 'jquery-yith-wcwl-user', $jquery );
}
add_action( 'wp_enqueue_scripts', 'yith_wcwl_custom_styles', 999 );
}
How it works: This code targets the wishlist container on a single product page and moves it to appear immediately after the 'Add to Cart' button. You can customize the jQuery selectors (e.g., .summary button.single_add_to_cart_button) to target different elements on your page.
Important: Always add custom code to a child theme's functions.php file to prevent it from being overwritten during theme updates.
2. Using a WordPress Hook
For a more straightforward approach, you can use a WordPress action hook to output the button in a specific location. This is often cleaner than DOM manipulation.
Example: Use the 'woocommerce_after_add_to_cart_button' hook
if( defined( 'YITH_WCWL' ) && ! function_exists( 'yith_wcwl_move_wishlist_button' ) ){
function yith_wcwl_move_wishlist_button(){
echo do_shortcode( '[yith_wcwl_add_to_wishlist]' );
}
add_action( 'woocommerce_after_add_to_cart_button', 'yith_wcwl_move_wishlist_button' );
}
After adding this code, you must also change the button's position in the plugin settings to "Use Shortcode" to prevent it from being printed in two locations.
3. Adjusting with Custom CSS
Once the button is in the right general area, you often need CSS for fine-tuning, such as adding margin or adjusting its display property to sit inline with other buttons.
Example: Add space above an element following the wishlist button
.product .summary .product_meta {
margin-top: 25px;
}
Example: Adjust the position of the button in a product loop
ul.products li.product .yith-wcwl-add-to-wishlist {
position: absolute;
top: 25px;
left: 30px;
z-index: 1;
}
Add CSS like this to your theme's Additional CSS section (Appearance > Customize > Additional CSS).
Removing Unwanted Text Labels
Another frequent request is to remove the text that appears next to the icon, such as "Remove from list." This can be achieved with a simple filter.
Example: Completely remove the 'Remove from list' text
add_filter( 'yith_wcwl_remove_from_wishlist_label', '__return_empty_string' );
Troubleshooting Tips
- Test First: Before making permanent changes, use a staging site or a test environment.
- Check for Conflicts: If a solution doesn't work, a theme or plugin conflict could be the cause. Temporarily switch to a default theme like Twenty Twenty-Four and disable other plugins to test.
- Selector Specificity: The jQuery and CSS selectors in these examples are based on common themes. You might need to inspect your page's HTML using your browser's developer tools to find the correct class names for your specific theme.
By combining these PHP, hook, and CSS techniques, you can gain full control over the placement and appearance of your YITH WooCommerce Wishlist button, ensuring it integrates perfectly with your store's design.
Related Support Threads Support
-
Remove all text labels for ‘add to wish list’ buttonhttps://wordpress.org/support/topic/remove-all-text-labels-for-add-to-wish-list-button/
-
Broken Add To Wishlist Texthttps://wordpress.org/support/topic/broken-add-to-wishlist-text/
-
Need help with positioning the buttonhttps://wordpress.org/support/topic/need-help-with-positioning-the-button/
-
How can i delete the Texthttps://wordpress.org/support/topic/how-can-i-delete-the-text/
-
Remove product from clickhttps://wordpress.org/support/topic/remove-product-from-click/
-
How to remove Wishlist titlehttps://wordpress.org/support/topic/how-to-remove-wishlist-title/
-
Wishlist Buttonshttps://wordpress.org/support/topic/wishlist-buttons/
-
Problems with displaying in the product listhttps://wordpress.org/support/topic/problems-with-displaying-in-the-product-list/
-
Button Text & Delete of Products in wishlisthttps://wordpress.org/support/topic/button-text-delete-of-products-in-wishlist/
-
remove from wishlist buttonhttps://wordpress.org/support/topic/remove-from-wishlist-button-2/
-
Remove all product on page Wishlisthttps://wordpress.org/support/topic/remove-all-product-on-page-wishlist/
-
Yith ‘count text’ overridehttps://wordpress.org/support/topic/yith-count-text-override-2/
-
Pop-up instead of link to wishlist pagehttps://wordpress.org/support/topic/pop-up-instead-of-link-to-wishlist-page/
-
Moving Wishlist button to next to Add to Cart buttonhttps://wordpress.org/support/topic/moving-wishlist-button-to-next-to-add-to-cart-button/
-
How to move the whole wishlist & add to cart buttons lower ?https://wordpress.org/support/topic/how-to-create-space-between-add-to-wishlist-add-to-cart/
-
Wishlist icon on hoverhttps://wordpress.org/support/topic/wishlist-icon-on-hover/
-
Remove the button add to wishlisthttps://wordpress.org/support/topic/remove-the-button-add-to-wishlist/
-
removing “added to wishlist” text from category pageshttps://wordpress.org/support/topic/removing-added-to-wishlist-text-from-category-pages/
-
How to move compare button beside Wishlist button?https://wordpress.org/support/topic/how-to-move-compare-button-beside-wishlist-button/
-
Wishlist button doesn’t look pretty after updatehttps://wordpress.org/support/topic/wishlist-button-doesnt-look-pretty-after-update/
-
Add to wishlist button in bootom of product imagehttps://wordpress.org/support/topic/add-to-wishlist-button-in-bootom-of-product-image/
-
How to move compare button beside wishlist button?https://wordpress.org/support/topic/how-to-move-compare-button-beside-wishlist-button-2/
-
Remove text when adding/removinghttps://wordpress.org/support/topic/remove-text-when-adding-removing/
-
remove text of shortcodehttps://wordpress.org/support/topic/remove-text-of-shortcode/
-
Remove from wishlist texthttps://wordpress.org/support/topic/remove-from-wishlist-text/
-
Wishlist below add to carthttps://wordpress.org/support/topic/wishlist-below-add-to-cart/
-
White rectangle appears when product added to wish listhttps://wordpress.org/support/topic/white-rectangle-appears-when-product-added-to-wish-list/
-
click and redirect to request list pagehttps://wordpress.org/support/topic/click-and-redirect-to-request-list-page/
-
Remove ‘add to wishlist’ overlayhttps://wordpress.org/support/topic/remove-add-to-wishlist-overlay/
-
Remove Items from Wishlist after Add to Carthttps://wordpress.org/support/topic/remove-items-from-wishlist-after-add-to-cart/
-
Move Wishlist button beside add to carthttps://wordpress.org/support/topic/move-wishlist-button-beside-add-to-cart/
-
Messages Boxes Add/Remove Items Displayhttps://wordpress.org/support/topic/messages-boxes-add-remove-items-display/
-
yith wishlist lightbox without borderhttps://wordpress.org/support/topic/yith-wishlist-lightbox-without-border/
-
Remove from wishlist – just show hearthttps://wordpress.org/support/topic/remove-from-wishlist-just-show-heart/
-
Add “Back to Shop” button on Wishlist pagehttps://wordpress.org/support/topic/add-back-to-shop-button-on-wishlist-page/
-
‘Add to Wishlist’ displayed within payment methodshttps://wordpress.org/support/topic/add-to-wishlist-displayed-within-payment-methods/
-
Placement of add to wishlist buttonhttps://wordpress.org/support/topic/placement-of-add-to-wishlist-button-2/
-
Change Whislist Button Positionhttps://wordpress.org/support/topic/change-whislist-button-position/
-
“Remove from list” button texthttps://wordpress.org/support/topic/remove-from-list-button-text/
-
Text after adding the Product to Wishlisthttps://wordpress.org/support/topic/text-after-adding-the-product-to-wishlist/
-
How to add more space after wishlist link.https://wordpress.org/support/topic/how-to-add-more-space-after-wishlist-link/
-
Add To Wishlist position settingshttps://wordpress.org/support/topic/add-to-wishlist-position-settings/
-
Add to Cart button instead Choose an Optionhttps://wordpress.org/support/topic/add-to-cart-button-instead-choose-an-option/
-
Remove from Wishlist text should not be shownhttps://wordpress.org/support/topic/remove-from-wishlist-text-should-not-be-shown/
-
remove add to wishlist on the homepage with php codehttps://wordpress.org/support/topic/remove-add-to-wishlist-on-the-homepage-with-php-code/
-
Remove add to wishlist in mobile versionhttps://wordpress.org/support/topic/remove-add-to-wishlist-in-mobile-version/
-
change location of wishlist buttonhttps://wordpress.org/support/topic/change-location-of-wishlist-button/