I am currently developing a plugin inside the admin page and I need to have a drop down list, listing all the pages. I need to be able to select one page and save the "ID" as an option. I am currently using this:
<select name="easyreg_redirect_page">
<option value=""><?php echo esc_attr( __( 'Select page' ) ); ?></option>
<?php
$pages = get_pages();
foreach ( $pages as $page ) {
$option = '<option value="' . $page->ID . '">';
$option .= $page->post_title;
$option .= '</option>';
echo $option;
}
?>
</select>
My 2 problems are:
1 - I would like the "Select Page" to always be available with an empty value (and I will make a check that it cannot be selected but this is an other story ;-) )
2 - When I come back to my plugin Admin page I would like to see the page name that is currently saved in the options, neither and empty line nor the "Select Page".