I must add level classes to every li when echoing the outcomes of wordpress_list_pages. Presently, I am using:


   wp_nav_menu(array('theme_location' => 'main_menu', 'container' => '', 'menu_class' => 'fR clearfix', 'menu_id' => 'nav'));

<?php } ?>

The preferred output could be:

<ul class="menu">
   <li class="page_item page-item-9 level-0 current_page_item"><a href="" title=""></a>
      <ul class="children expanded" style="display: block; ">
        <li class="page_item page-item-40 level-1"><a href="" title=""></a></li>
        <li class="page_item page-item-43 level-1"><a href="" title=""></a></li>
        <li class="page_item page-item-45 level-1"><a href="" title=""></a></li>
        <li class="page_item page-item-47 level-1"><a href="" title=""></a></li>
   <!-- So on -->

Is possible to achieve the preferred output? help!

It is best to make use of a custom master to include that class. See Cleaner output for wp_nav_menu() and Improve your Wordpress Navigation Menu Output and T5_Nav_Menu_Walker_Simple — Gist

There is not an immediate method of doing this.

You should use the wordpress_nav_menu_objects filter and manipulate recption menus item's classes.

This is actually the code for you personally:

add_filter('wp_nav_menu_objects' , 'my_menu_class');
function my_menu_class($menu) {
    $level = 0;
    $stack = array('0');
    foreach($menu as $key => $item) {
        while($item->menu_item_parent != array_pop($stack)) {
        $stack[] = $item->menu_item_parent;
        $stack[] = $item->ID;
        $menu[$key]->classes[] = 'level-'. ($level - 1);
    return $menu;        

it can help you...

<?php wp_list_pages('title_li='); ?>