我正在尝试使用将我自己的字段添加到菜单中get_template_part
。问题是我的代码不能正常工作,因为它在外面
<ul id="primary-menu" class="nav-menu">
这是php:
<?php
$open_g = get_template_part('template/open_google_nav', false);
$items_wrap = '<ul id="%1$s" class="%2$s">%3$s';
$items_wrap .= sprintf( '<li id="item-google-nav">%1$s</li></ul>', $open_g );
wp_nav_menu(
array(
'items_wrap' => $items_wrap,
'theme_location' => 'desktop-menu',
'menu_class' => 'nav-menu',
'menu_id' => 'primary-menu',
)
);
?>
这是从 PHP 生成的 HTML
<nav id="primary-navigation" class="site-navigation primary-navigation" role="navigation">
"My template part" --> Here is my template part
<div class="menu-glowne-menu-container">
<ul id="primary-menu" class="nav-menu">
<li id="menu-item-32" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-32"><a href="#"><span class="menu-item-description">Desc</span>Menu 1</a></li>
<li id="menu-item-31" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-31"><a href="#"><span class="menu-item-description">Desc</span>Menu 2</a></li>
<li id="menu-item-30" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-30"><a href="#"><span class="menu-item-description">Desc</span>Menu 3</a></li>
<li id="item-google-nav">HERE SHOULD BE MY TEMPLATE PART</li>
</ul>
</div>
</nav>
我究竟做错了什么?