Add a class to main menu links I've searched and found variations of this question but I've never found an answer that seemed to work. I need to add a class to the &lt;li&gt; elements, currently the main menu is rendered like this:

print theme('links__system_main_menu', array(
    'links' =&gt; $main_menu,
    'attributes' =&gt; array(
        'id' =&gt; 'slidemenu',
        'class' =&gt; array(
            'links',
            'inline',
            'clearfix'
        )
    ),
    'heading' =&gt; t('')
));


As far as I can tell, this only sets up the &lt;ul&gt; element of the main menu, so I was wondering if there's a way to edit the attributes of the 'links' part.

---EDIT---

Alright, I think I solved it. Apparently you can use theme_links__system_main_menu in templates to override the whole thing. I ended up doing this:

function mytheme_links__system_main_menu($variables) {
    $html = '&lt;div id="mainmenu"&gt;';
    $html .= '  &lt;ul id="slidemenu" class="clearfix"&gt;';

    static $linkClass = 1;

    foreach ($variables['links'] as $link) {                
        $html .= '&lt;li class="themastyle' . $linkClass . '"&gt;' . l($link['title'], $link['href'], $link) . '&lt;/li&gt;';
        ++$linkClass;
    }

    $html .= '  &lt;/ul&gt;';
    $html .= '&lt;/div&gt;';

    return $html;
}


Not entirely sure if this is correct Drupal, though it did solve my issue!
Menu Attributes is another great module that allows you to set class, id, rel and other attributes on either the a or li element.