I am utilizing a Wordpress theme and I am adding a brand new configurations option while using Wordpress configurations API.

What I wish to do is possess a drop-lower list that populates in the database of wordpress pages on my small site after which possess the user choose the page they need for that particular option.

What's happening with my current code is it will populate and choose the page - even save it to my database, however when I open the options' page again, however, it reverts the choice that is displayed towards the default option - it is not altering anything within the database, it's not exhibiting the choice that's within the database if this loads. Any ideas?

this is actually the function im using to show the dropdown list :

 function  setting_dropdown_fn() {
$options = get_option('wellness_options');
echo "<select name='wellness_options[page_string]'>" ;
   $pages = get_pages(); 
  foreach ( $pages as $pagg ) {
$option = '<option value="' . get_page_link( $pagg->ID ) . '">';
$option .= $pagg->post_title;
$option .= '</option>';
echo $option;
echo '</select>';}

You have to set the because the "selected" option whenever you output the drop lower list. The HTML output (after page 3 continues to be held in the database) would seem like:

<select id="whatever" name="whatever">
  <option value="1">First Page</option>
  <option value="2">Second Page</option>
  <option value="3" selected="selected">Third Page</option>
  <option value="4">Fourth Page</option>

WordPress includes a assistant1 function which makes this simpler, in the for/foreach loop you should use:

<?php selected($value_in_database, $value_of_this_option); ?>

That code results the selected="selected" for you personally whether it's needed.