Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Need a little bit of help here. I am adding this dropdown to my options panel. However, when I call my option in my template. It does not display

Here is the function for the dropdown:

    function page_test_setting(){
    $options = get_option('meta_options');
    $pages = get_pages(); 
    echo '<select name="meta_options[page_test]">'; 
    echo "<option value='{$options['page_test']}'>";
    echo esc_attr( __( 'Select page' ) );
    echo "</option>"; 
    foreach ( $pages as $page ) {
    $option = '<option value="' . get_page_link( $page->ID ) . '">';
    $option .= $page->post_title;
    $option .= '</option>';
    echo $option;
    echo '</select>';
    }
    }

The options field:

    add_settings_field('page_test', 'PAGE OUTPUT', 'page_test_setting', __FILE__, 'meta_section');

And here is how I am calling it in my theme:

   <?php echo get_permalink($options['page_test']); ?>

As you can probably guess is that I want the CALL to pull the page title and link to the appropiate page. Should I be using page titles instead for the call or what?

share|improve this question

1 Answer 1

Okay, I found the solution incase anyone else is need to do the same thing.

 function music_link_setting (){
    $options = get_option('kw_theme_options');
    wp_dropdown_pages(
    array(
         'name' => 'kw_theme_options[music_link]',
         'echo' => 1,
         'show_option_none' => __( '&mdash; Select &mdash;' ),
         'option_none_value' => '0',
         'selected' => $options['music_link']
    )
);

}

share|improve this answer

Your Answer

 
discard

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.