Home Forums Backend Issues (wp-admin) Can't display a new field in menu items


Can't display a new field in menu items

  • Hi guys,

    My name is Davide and I’m working on my new project, but I have a big iussue I can’t figure out how to fix it. I’m trying to put a second line of text in menu items on the main menu of wordpress. I added a new field in ACF Field Group and it works. I added the text in the backend of the menu and I added the code that I found in ACF documentation but… Nothing changed. Maybe there is some kind of error but I can’t figure out where it could be.

    Can someone help me to find out how to solve this?

    Thnaks guys,

    PS: I post here some screen and my code in order to help you on understading what I’ve done until now

    *** Screen of ACF Field Group ***
    Click me

    *** functions.php code ***

    //Navbar from Bootstrap 4 to WordPress
    require_once get_template_directory() . '/wp-bootstrap-navwalker.php';
    //Add the subtitle field with Advanced Custom Fields
    add_filter('wp_nav_menu_objects', 'my_wp_nav_menu_objects', 10, 2);
    function my_wp_nav_menu_objects( $items, $args ) {
    	foreach( $items as &$item ) {
    		$menu_navbar_sottotitolo = get_field('menu_navbar_sottotitolo', $item);
    		if( $icon ) {
    			$item->title .= '<br/><small>'.$menu_navbar_sottotitolo.'</small>';
    	return $items;

    *** header.php code ***

    <header class="site-header" role="banner">
    	<div id="mainNav" class="navbar navbar-expand-lg fixed-top unselectable">
    		<div class="container">
    			<a class="navbar-brand" href="index.html">
    				JustWeb Factory
    			<button class="navbar-toggler navbar-toggler-right" type="button" data-toggle="collapse" data-target="#navbarContent" aria-controls="navbarContent" aria-expanded="false" aria-label="Toggle navigation">
    				<i class="fa fa-bars"></i>
    				wp_nav_menu( array(
    					'menu'              => 'primary',
    					'theme_location'    => 'primary',
    					'depth'             => 2,
    					'container'         => 'div',
    					'container_class'   => 'collapse navbar-collapse',
    					'container_id'      => 'navbarContent',
    					'menu_class'        => 'navbar-nav ml-auto',
    					'fallback_cb'       => 'WP_Bootstrap_Navwalker::fallback',
    					'walker'            => new WP_Bootstrap_Navwalker())

    *** Actual navbar ***
    Click me

    *** Desired navbar ***
    Click me

  • change this:

    $menu_navbar_sottotitolo = get_field('menu_navbar_sottotitolo', $item);
    		if( $icon ) {
    			$item->title .= '<br/><small>'.$menu_navbar_sottotitolo.'</small>';

    to this:

    $menu_navbar_sottotitolo = get_field('menu_navbar_sottotitolo', $item);
    		if( $menu_navbar_sottotitolo ) {
    			$item->title .= '<br/><small>'.$menu_navbar_sottotitolo.'</small>';
  • I love you man, thanks!!!

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.