我在模板中找到了一个函数,它在菜单的末尾添加了一个注册按钮。我想知道是否有任何方法可以让这个功能将注册按钮添加到菜单项的开头?
add_filter(\'wp_nav_menu_items\', \'vertoh_wp_nav_menu_items\', 10, 2);
function vertoh_wp_nav_menu_items($items, $args) {
$widget_ef_registration = get_option(\'widget_ef_registration\');
if ($args->theme_location == \'primary\' && is_active_widget(false, false, \'ef_registration\') && is_array($widget_ef_registration)) {
foreach ($widget_ef_registration as $key => $reg_widget) {
if (empty($reg_widget)) {
unset($widget_ef_registration[$key]);
update_option(\'widget_ef_registration\', $widget_ef_registration);
} elseif (isset($reg_widget[\'registrationshowtopmenu\']) && $reg_widget[\'registrationshowtopmenu\'] == 1) {
$registration_topmenu_url = !empty($reg_widget[\'registrationtopmenuurl\']) ? $reg_widget[\'registrationtopmenuurl\'] : \'#tile_registration_anchor\';
$items .= \'<li class="register"><a href="\' . $registration_topmenu_url . \'" class="section-button">\' . stripslashes($reg_widget[\'registrationtopmenutext\']) . \'</a></li>\';
break;
}
}
}
return $items;
}