答案 0 :(得分:0)
我认为最简单的方法是过滤wp_dropdown_...
的输出并在结束select
标记之前注入您的选项;
function insert_home_in_dropdown($output)
{
$end = '<option value="whatever">Home</option></select>';
return preg_replace('#</select>$#', $end, trim($output));
}
add_filter('wp_dropdown_pages', 'insert_home_in_dropdown');
答案 1 :(得分:0)
我的代码看起来像这样,在我的functions.php代码中,我将值编辑为0。
var dropdownf = document.getElementById("page_id");
function onPageChange() {
if ( dropdownf.options[dropdownf.selectedIndex].value > 0 ) {
location.href = "<?php echo get_option('home'); ?>/?page_id="+dropdownf.options[dropdownf.selectedIndex].value;
}
if ( dropdownf.options[dropdownf.selectedIndex].value == 0 ) {
location.href = "<?php echo get_option('home'); ?>"; // this give the href to the home link
}
}
dropdownf.onchange = onPageChange;