当我按照wp get nav菜单项读取nav项时,get\\u page\\u链接($id)或$item->url
没有提供我输入的外部URL:http://www.mydomain.com.
相反,我似乎http://www.mydoamin.com/wordpress/NameOfMenuItem
有什么想法吗?
我正在使用permalinks,我想这可能是问题所在?
这是菜单代码:
<?php
函数bfShowHideMenu($menu\\u name,$args=array()){
// Klassen von außen bestückbar
$bfListClass = "no-bullet bfZ1000";
$bfItemClassLevel1 = "";
$bfItemClassLevel2 = "";
$bfLinkClass = "navitem";
$bfContainerClass = "subScrollNavi";
$locations = get_nav_menu_locations();
$menu = wp_get_nav_menu_object( $locations[ $menu_name ] );
$menuitems = wp_get_nav_menu_items( $menu->term_id );
echo \'<ul class="\' . $bfListClass . \'">\';
$count = 0;
$submenu = false;
foreach( $menuitems as $item ):
// get page id from using menu item object id
$id = get_post_meta( $item->ID, \'_menu_item_object_id\', true );
// set up a page object to retrieve page data
$page = get_page( $id );
//$link = get_page_link( $id );
$link = $item->url;
// item does not have a parent so menu_item_parent equals 0 (false)
if ( !$item->menu_item_parent ):
// save this id for later comparison with sub-menu items
$parent_id = $item->ID;
// Hat der Knoten Kinder?
$hasChildren = false;
foreach( $menuitems as $child ){
if ($child->menu_item_parent == $parent_id) {
$hasChildren = true;
break;
}
}
echo \'<li class="\';
if ($hasChildren) echo "bfSHTrigger";
echo \' \' . $bfItemClassLevel1 . \'">\';
echo \'<a href="\' . $link . \'" class="\' . $bfLinkClass . \'">\';
echo mb_strtoupper($page->post_title);
echo \'</a>\';
endif;
if ( $parent_id == $item->menu_item_parent ):
if ( !$submenu ):
$submenu = true;
echo \'<div class="bfSHContainer bfSHSubScrollNavi \' . $bfContainerClass . \'">\';
echo \'<ul class="\' . $bfListClass . \'">\';
endif;
echo \'<li class="\' . $bfItemClassLevel2 . \'">\';
echo \'<a href="\' . $link . \'" class="\' . $bfLinkClass . \'">\' . mb_strtoupper($page->post_title) . \'</a>\';
echo \'</li>\';
if ( $menuitems[ $count + 1 ]->menu_item_parent != $parent_id && $submenu ):
echo \'</ul>\';
echo \'</div>\';
$submenu = false;
endif;
endif;
if ( $menuitems[ $count + 1 ]->menu_item_parent != $parent_id ):
echo \'</li>\';
$submenu = false;
endif;
$count++;
endforeach;
echo \'</ul>\';
}
?>