Render main menu in page.tpl.php, with override from template.php In Drupal 7, I'm trying to add a &lt;span&gt; tag inside the &lt;a&gt; tag of an item in the Main Menu, but it only works for the 'Navigation' menu which is a block, however, I am trying render it within page.tpl.php

I've been searching this up for a while now and can't seem to get it to work. 
I was attempting to follow the information from How do I insert a &lt;span&gt; &lt;/span&gt; tag inside the &lt;a&gt; &lt;/a&gt; tag on my main menu

Here's a snippet from page.tpl.php 

  &lt;nav id="main-menu" class="navigation span8"&gt;
    &lt;?php print theme('links__system_main_menu', array(
      'links' =&gt; $main_menu,
      'attributes' =&gt; array(
        'id' =&gt; 'main-menu-links',
        'class' =&gt; array('links', 'clearfix'),
      ),
      'heading' =&gt; array(
        'text' =&gt; t('Main menu'),
        'level' =&gt; 'h2',
        'class' =&gt; array('element-invisible'),
      ),
     )); ?&gt;
  &lt;/nav&gt; &lt;!-- /#main-menu --&gt;


and from template.php

function THEMENAME_menu_link(array $variables) {
  $element = $variables['element'];
  $sub_menu = '';

//$element['#attributes']['class'][] = 'menu-' . $element['#original_link']['mlid'];

$get_title= $element['#title'];
$element['#title']='&lt;span&gt;' . $get_title .' &lt;/span&gt;';

$element['#localized_options'] += array(
    'attributes' =&gt; array(), 
    'html' =&gt; TRUE,
  );

  if ($element['#below']) {
    $sub_menu = drupal_render($element['#below']);
  }
  $output = l($element['#title'], $element['#href'], $element['#localized_options']);
  return '&lt;li' . drupal_attributes($element['#attributes']) . '&gt;' . $output . $sub_menu . "&lt;/li&gt;\n";
}
The function you need to override is theme_links() and to do that just for the main menu you can use mytheme_links__system_main_menu as the function name. To add span tags you can then modify the part that starts with if (isset($link['href'])):

if (isset($link['href'])) {
  // Pass in $link as $options, they share the same keys.
  $link['html'] = TRUE;
  $output .= l('&lt;span&gt;'. check_plain($link['title']) .'&lt;/span&gt;', $link['href'], $link);
}