Support » Themes and Templates » settings API dropdown list to select page

  • Resolved accounts@push


    hi there i’m attempting to difine a function that will display a dropdown list of the pages on my wordpress site – currently my functions.php file resembles closely to otto’s wordpress settings API tutorial found here.

    currently i am using the following function to display a dropdown list and am able to get it to populate the <select> tag with my pages however when i chose the page and submit it the option does not save to my database.

    function  setting_dropdown_fn() {
    	$options = get_option('rtms_options');
    	$args = array(
        'depth'            => 0,
        'child_of'         => 0,
        'selected'         => 0,
        'echo'             => 1,
        'name'             => "rtms_options[Page_string]",
    	'id'			   => "dropdown")
    	wp_dropdown_pages( $args );

    any advice on where i’m going wrong or where i need to be looking into would be very helpful – as i said before i’m trying to now save the populated list selection to my database

Viewing 2 replies - 1 through 2 (of 2 total)
  • the following code will do the same in terms of populating the list however it will not save either.

    function  setting_dropdown_fn() {
    	$options = get_option('rtms_options');
    	echo "<select name='page-dropdown'>
     <option value=''>";
    echo esc_attr( __( 'Select page' ) ); ?></option>
      $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>';}

    Did you end up with a solution?

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘settings API dropdown list to select page’ is closed to new replies.