Either use output buffering:
// Email Archives Shortcode
function email_archives_shortcode() {
ob_start(); ?>
<select name="archive-dropdown" onchange="document.location.href=this.options[this.selectedIndex].value;">
<option value=""><?php echo esc_attr( __( 'Select Month' ) ); ?></option>
<?php wp_get_archives( array( 'type' => 'monthly', 'format' => 'option', 'show_post_count' => 1, 'post_type' => 'emails' ) ); ?>
</select>
<?php return ob_get_clean();
}
add_shortcode('email-archives', 'email_archives_shortcode');
Or a string
function email_archives_shortcode() {
return sprintf(
'<select name="archive-dropdown" onchange="document.location.href=this.options[this.selectedIndex].value;">
<option value="">%1$s</option>
%2$s
</select>',
esc_attr( __( 'Select Month' ) ),
wp_get_archives( array(
'type' => 'monthly',
'format' => 'option',
'show_post_count' => 1,
'post_type' => 'emails',
echo => false,
) )
);
}
add_shortcode('email-archives', 'email_archives_shortcode');