Instantly share code, notes, and snippets.

What would you like to do?
Adding WooCommerce cart link to wp_nav_menu()
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;
<?php wp_nav_menu(array(
'theme_location' => 'my_menu_location',
'items_wrap' => my_nav_wrap()
)); ?>

This comment has been minimized.

NickToye commented Mar 8, 2016


This doesn't work. It prints out > class="cart_totals">


This comment has been minimized.

loversjain commented Jun 1, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment