WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm building a themes options page using settings API. Everything is ok, but i now i want to create a drop down list populated with pages and i don't know how to!

For example, i have this piece of code that show the list of pages, but when i select a page and cick on save, the page selected doesn't get saved!

    function  combo_select_page_callback() {
$options = get_option('journal_theme_blog_2_col');
    echo "<select name='select_page'>
 <option value=''>";
echo esc_attr( __( 'Select page' ) ); ?></option>
  $pages = get_pages();
  foreach ( $pages as $page ) {
    $selected = '<option value="' . get_page_link( $page->ID ) . '">';
    $selected .= $page->post_title;
    $selected .= '</option>';
    echo $selected;
echo '</select>';
}// end combo_select_page_callback

Thank for the help, nelson

share|improve this question
Add the code you use to save the data. – toscho Jul 19 '12 at 10:47
I think i have found the solution: – naires Jul 19 '12 at 11:06
@naires Then add it as answer, wait for two days and mark it as solution. – kaiser Jul 27 '12 at 2:02
You are right kaiser. i just did. thank you for the attention. – naires Jul 27 '12 at 8:54
up vote 1 down vote accepted

I have found the solution. I used the wordpress function wp_dropdown_pages

<?php function  combo_select_page_callback() {
$options = get_option('function plugin');
             'name' => 'function plugin[ID used to identify the field throughout the theme]',
             'echo' => 1,
             'show_option_none' => __( '&mdash; Select &mdash;' ),
             'option_none_value' => '0',
             'selected' => $options['ID used to identify the field throughout the theme']
} ?>
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.