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.

I show the all menu which i have on the top in dropdown style when site is open in mobiles. I successfully display them in dropdown style but the problem is that how can i indend my subpages. or make parent pages bolg is any way to do that, my code is

<nav id="nav-mobile" role="navigation">
                <select id="mob_menu" name="page-dropdown"> 
                 <option value="">
                <?php echo esc_attr( __( 'Select page' ) ); ?></option> 
                 <?php 
                  $pages = get_pages(); 
                  foreach ( $pages as $page ) {
                    $option = '<option value="' . get_page_link( $page->ID ) . '">';
                    $option .= $page->post_title;
                    $option .= '</option>';
                    echo $option;
                  }
                 ?>
                </select>

                </nav>
share|improve this question
    
You indent and change the font-weight (bold) the output with CSS. There doesn't seem to be anything WordPress specific to this question. –  s_ha_dum May 22 '13 at 14:27

1 Answer 1

up vote 0 down vote accepted

Use wp_dropdown_pages():

print '<form action="' . home_url() . '">';
wp_dropdown_pages();
print '<input type=submit></form>';

You get a select field with proper indentation, and clicking on the button will send the user to that page.

enter image description here

share|improve this answer
    
Thanks lots, this is the result i need. –  Adi May 22 '13 at 15:14

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.