Last active
June 1, 2016 12:05
-
-
Save galengidman/440d4379a2059b206ca8 to your computer and use it in GitHub Desktop.
Adding WooCommerce cart link to wp_nav_menu()
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function my_nav_wrap() { | |
$wrap = '<ul id="%1$s" class="%2$s">'; | |
$wrap .= '%3$s'; | |
$wrap .= '<li class="cart">'; | |
$wrap .= '<a href="' . WC()->cart->get_cart_url() . '"> class="cart_totals">'; | |
$wrap .= WC()->cart->get_cart_total(); | |
$wrap .= '</a>'; | |
$wrap .= '</li>'; | |
$wrap .= '</ul>'; | |
return $wrap; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<nav> | |
<?php wp_nav_menu(array( | |
'theme_location' => 'my_menu_location', | |
'items_wrap' => my_nav_wrap() | |
)); ?> | |
</nav> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi,
This doesn't work. It prints out > class="cart_totals">