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> 
                  $pages = get_pages(); 
                  foreach ( $pages as $page ) {
                    $option = '<option value="' . get_page_link( $page->ID ) . '">';
                    $option .= $page->post_title;
                    $option .= '</option>';
                    echo $option;

  • 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

Use wp_dropdown_pages():

print '<form action="' . home_url() . '">';
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


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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