Get menu links only

Use a custom walker:

class WPSE_33175_Simple_Walker extends Walker
{
    public function walk( $elements, $max_depth )
    {
        $list = array ();

        foreach ( $elements as $item )
            $list[] = "<a href="https://wordpress.stackexchange.com/questions/33175/$item->url">$item->title</a>";

        return join( "\n", $list );
    }
}

… and then call wp_nav_menu() like this:

wp_nav_menu(
    array (
        'theme_location' => 'your_registered_theme_location',
        'walker'         => new WPSE_33175_Simple_Walker,
        'items_wrap'     => '<nav>%3$s</nav>'
    )
);

Leave a Comment

tech