Skip to content

Instantly share code, notes, and snippets.

@galengidman
Created December 26, 2015 19:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save galengidman/d9b4a27ed08fb68a4a6a to your computer and use it in GitHub Desktop.
Save galengidman/d9b4a27ed08fb68a4a6a to your computer and use it in GitHub Desktop.
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