You’re not actually outputting the selected
attribute into the <option>
tag. Look at your printf()
format:
'<option value="%u">%s</option>'
%u
is there for the month’s number value, and %s
is there for month’s name, but you’re not including the last argument from the result of selected()
.
Your printf()
needs to look like this:
printf(
'<option value="%u" %s>%s</option>',
$num,
selected( $birth_date_month, $num, false ),
$month
);
Note that I swapped the order of the arguments, because selected
needs to be output before the month name.