How to split the "My Account" WooCommerce tabbed menu in three different sections.
Here is the current code that I got:
<nav class="woocommerce-MyAccount-navigation">
<ul>
<?php foreach ( wc_get_account_menu_items() as $endpoint => $label ) : ?>
<li class="<?php echo wc_get_account_menu_item_classes( $endpoint ); ?>">
<a href="<?php echo esc_url( wc_get_account_endpoint_url( $endpoint ) ); ?>"><?php echo esc_html( $label ); ?></a>
</li>
<?php endforeach; ?>
</ul>
</nav>
What I need: I have a total 15 menu items to split this way:
<ul>
<ul>
<ul>
Please help me how to fix this.
Thanks
This is very easy adding a counter that will add </ul><ul>
after the 5th and the 9th menu items. See below:
<nav class="woocommerce-MyAccount-navigation">
<ul>
<?php
$count = 0; // Initializing the count variable
foreach ( wc_get_account_menu_items() as $endpoint => $label ) :
?>
<li class="<?php echo wc_get_account_menu_item_classes( $endpoint ); ?>">
<a href="<?php echo esc_url( wc_get_account_endpoint_url( $endpoint ) ); ?>"><?php echo esc_html( $label ); ?></a>
</li>
<?php
$count++; // increasing count
if($count == 5 || $count == 9 ) echo '</ul><ul>'; // Adding <ul>
endforeach;
?>
</ul>
</nav>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.