Best way to dynamically change only the href of a link in the main menu not the markup I have been digging quite a bit for this and cannot believe that I am not finding way to do this as I didn't think it would be all that difficult. I would like to alter the href property of my main menu items (potentially) on each page load. 

I am building a site that will take the state name in to consideration on most pages. The default main menu links do not contain the state names in the urls. I want to be able to check for the existence of a state name on a given page, and when present, append that to all the main menu items so that the state continues to be taken in to consideration on future pages. 

I have seen solutions for theming links, but I do not wish to change the markup of my main menu in any way, I simply want to have the link go to a new location. I would much prefer to do this on the server side rather than using jquery to update them. 

Here is what I thought would work:

function THEME_preprocess_page(&amp;$variables) {

  foreach($variables['main_menu'] as $key =&gt; $item) {
    $variables['main_menu'][$key]['href'] = 'my_new_url';
  }
}


However, when I print the results, I see that the values in $variables are changed, but they are not reflected in the markup. Is there another simple way that I can do this without having to rewrite the markup of my menu with a theme_links__system_main_menu() call?
Check out theme_menu_link. You can add it to the template.php file of your subtheme. Be sure to return the correctly formatted string.