how to get the post id in the option tag
$post->id needs to be $post->ID You can also use get_the_ID() Since your calling setup_postdata() you need to call wp_reset_postdata() after your foreach loop. You also need to echo the value of $options somewhere. foreach( $myposts as $post ) : setup_postdata($post); $options .= ‘<option>’; $options .= ‘<option value=”‘.$post->id.'”>’; $options .= get_the_title(); $options .= ‘</option>’; echo $options; … Read more