How can I code Wordpress page in Drop Down List?
How can I 开发者_开发百科do code the wordpress page into dropdown list something like this Page 1 Page 2 Page 3
and then when I click submit it goes to the selected page.. .thank you so much guys in advance.. .
-idontknowhow
Use get_pages to fech all the pages under the system, there's an example to do exactly what you want:
<select name="page-dropdown"
onchange='document.location.href=this.options[this.selectedIndex].value;'>
<option value=""><?php echo attribute_escape(__('Select page')); ?></option>
<?php
$pages = get_pages();
foreach ($pages as $pagg) {
$option = '<option value="'.get_page_link($pagg->ID).'">';
$option .= $pagg->post_title;
$option .= '</option>';
echo $option;
}
?>
</select>
精彩评论