我正在尝试将帖子的特色图片添加到我的大菜单中。我想在div标签中显示特色图像。如何在sprintf函数中添加特色图像?
$thumbnail = \'\';
if ( has_post_thumbnail( $item->object_id ) ) {
$thumbnail = the_post_thumbnail_url( $item->object_id );
}
class Walker_Nav_Primary extends Walker_Nav_menu {
function start_el( &$output, $item, $depth = 0, $args = array(), $id = 0 ) {
if ( array_search( \'menu-item-has-children\', $item->classes )&& $depth==0 ) {
$output .= sprintf( "\\n<li class=\'topnavitem %s\'><a href=\'%s\' class=\\"topnavtext\\">%s</a>\\n", ( array_search( \'current-menu-item\', $item->classes ) || array_search( \'current-page-parent\', $item->classes ) ) ? \'\' : \'\', $item->url, $item->title );
}
elseif ( array_search( \'menu-item-has-children\', $item->classes )&& $depth==1 ) {
$output .= sprintf( "\\n<li class=\'productsnav %s\'><a href=\'%s\' class=\\"productsnavtext\\">%s</a>\\n", ( array_search( \'current-menu-item\', $item->classes ) || array_search( \'current-page-parent\', $item->classes ) ) ? \'\' : \'\', $item->url, $item->title );
}
elseif ($depth==2){
$output .= sprintf( "\\n<li class=\'secondnavitem %s\'>
<div class=\'pictext\'> \\\\I want the featured image here
<a href=\'%s\' class=\\"secondnavtext\\">%s</a>\\n", ( array_search( \'current-menu-item\', $item->classes) ) ? \'\' : \'\', $item->url, $item->title );
}
else {
$output .= sprintf( "\\n<li class=\'topnavitem %s\'><a href=\'%s\' class=\\"topnavtext\\">%s</a>\\n", ( array_search( \'current-menu-item\', $item->classes) ) ? \'\' : \'\', $item->url, $item->title );
}
}
function start_lvl( &$output, $depth ) {
$indent = str_repeat( "\\t", $depth );
if ($depth == 0) {
$output .= "\\n$indent<ul class=\\"nav-level-one\\" role=\\"submenu\\">\\n";
}
if ($depth == 1) {
$output .= "\\n$indent<ul class=\\"nav-level-two\\" role=\\"subsubmenu\\">\\n";
}
}
}