我正在使用一個功能在WordPress導航菜單中顯示已登錄的用戶名,並且我還想在菜單中顯示已登錄的用戶頭像,但找不到一種方法來做到這一點。所以我問一些幫助:) 這裏是我使用的名稱的功能:在Wordpress導航菜單中顯示已登錄的用戶頭像
function my_dynamic_menu_items($menu_items) {
foreach ($menu_items as $menu_item) {
if ('#current-username#' == $menu_item->title) {
global $shortcode_tags;
if (isset($shortcode_tags['current-username'])) {
// Or do_shortcode(), if you must.
$menu_item->title = call_user_func($shortcode_tags['current-username']);
}
}
}
return $menu_items;
}
add_filter('wp_nav_menu_objects', 'my_dynamic_menu_items');
我有我的functions.php這個代碼,我用#當前戶名#中調用它一個菜單項,有沒有辦法自定義這個代碼也輸出頭像?謝謝你的幫助。
感謝Mansukh,對於最近的回覆感到抱歉,這有助於我管理它:) – Neokentin
好的。好,所以我的答案給予聲譽... –