We searched for this tirelessly!
In order to add the “Add to wishlist” button into your custom built content-single-product.php you must add this line to the top of your file:
global $wishlists;
Then add this code where you want the button to appear:
$wishlists -> add_wishlist_form();
Done.
If you need it without the quantity field just use this instead for the second part:
<form class="cart" method="post" enctype='multipart/form-data' action="<?php echo add_query_arg( array('add-to-wishlist-itemid' => $product->id), $product->add_to_cart_url() ); ?>"> <input type="hidden" name="add-to-cart" value="<?php echo esc_attr( $product->id ); ?>" /> <?php $wishlists->add_to_wishlist_button(); ?> </form>
marcio
Jan 6, 2015 -
Brother! U saved my life!
Rachel
Feb 4, 2015 -
OMG you’re my hero right now. Thank you, thank you, thank youuuu!
Andred
Mar 8, 2015 -
Thank you so much!
Fernando
Aug 30, 2015 -
Really useful! thanks
Marshall
Jan 6, 2016 -
I’m trying to add a wish list button to a catergory page like https://bellacabinetsupply.com/cabinets/silver/boston-vintage-white/
I found code to add to the functions.php file at http://www.remicorson.com/woocommerce-display-add-to-wishlist-button-on-shop-page/
It displays and pull up my wishlist to add to them but does not post to them.
I can’t seem to get registered at his site.
Any ideas would be helpful.
jim
Jul 2, 2019 -
damn, thanks for this, saved my butt
Gustavo
Oct 14, 2019 -
For fuck sake! im trying to find something simple as this for days!!!! it seems as the support from the plugin only tries to make things harder…. THANK FUCKING YOU SIR! What a great and useful person you are!
zia zafar ansari
Jan 23, 2020 -
Hello
how to get yith wishlist page url for wishlist button
Thank you