First, you need to get the title of the current page. Something like this:
$current = apply_filters('the_title',$post->post_title);
Then after you get the title of the item you are processing, you can check it against $current:
$title = $menu_item->title;
$selected = ($title == $current) ? ' selected="selected" ' : '';
Ok cool. I’ll will try that!
But look: three of my menu items are category-archives. So when I’m on an article page, how do I assign selected="selected" to the category item of my select list?
Thank you!
That could be tricky unless all your posts are assigned only a single parent category. If that is true, you should be able to use this:
$category = get_the_category();
$title = $category[0]->cat_name;
Then compare to the menu_item title as before.
If your posts are in more than one category, or in child categories, this will not work. I do not have a solution for that case.