下面是一种使用WordPress wp\\u dropdown\\u pages()函数从博客页面生成下拉菜单的简单方法。
添加一点javascript,当用户选择页面时,您可以将其发送到该页面
<section id="pageselect">
<span>
<?php wp_dropdown_pages(\'show_option_none=Explore...\'); ?>
</span>
<script type="text/javascript"><!--
var selectmenu = document.getElementById("page_id");
function onPageChange() {
if ( selectmenu.options[selectmenu.selectedIndex].value > 0 ) {
location.href = "<?php echo get_option(\'home\'); ?>/?page_id="+selectmenu.options[selectmenu.selectedIndex].value;
}
}
selectmenu.onchange = onPageChange;
--></script>
</section><!-- end pageselect -->