the_permalink()
, the_title()
by default echo
their value. As you want to store that value in a variable you will need to return
the values instead.
get_the_permalink()
, get_the_title()
are two similar functions that return
the value instead of echo
.
So you new code may look something like this:
$list="<li class="ubermenu-submenu ubermenu-submenu-id-122-col-0 ubermenu-submenu-type-stack">";
$list .= '<a class="ubermenu-target ubermenu-target-with-icon ubermenu-item-layout-icon_left" href="';
$list .= get_the_permalink();
$list .= '" title="';
$list .= get_the_title();
$list .= '"><span class="ubermenu-target-title ubermenu-target-text">';
$list .= get_the_title();
$list .= '</span></a></li>';