Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Convert wp_page_menu() to wp_nav_menu() markup
<?php
$html = wp_page_menu( array(
'echo' => false,
'depth' => 2
) );
$html = str_replace( ' page_item_has_children', ' menu-item-has-children', $html );
$html = str_replace( ' current_page_item', ' current-menu-item', $html );
$html = str_replace( ' page-item-', ' menu-item-', $html );
$html = str_replace( 'class="page_item', 'class="menu-item', $html );
$html = str_replace( "class='children'", 'class="sub-menu"', $html );
return $html;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment