Adding a section in line at the end of the main navigation menu in php

https://developer.wordpress.org/reference/hooks/wp_nav_menu_menu-slug_items/

function my_nav_menu_primary_navigation($items, $args) { 
  $items .= '<li>Hello :D</li>'; 
  return $items; 
}

add_filter( "wp_nav_menu_{MENU SLUG}_items", "my_nav_menu_primary_navigation", 10, 2 );

find {MENU SLUG}

EDIT:

The “wp_nav_menu_menu-slug_item” filter runs at the end near the end of wp_nav_menu, $ items is a string containing the HTML extructura the menu and $ args are the arguments that you passed to the function “wp_nav_menu”.

The only thing that you have to look out for or seek to use this is what the “{MENU SLUG}” on your menu.

This is a translation of google, do not write in English: D


In Spanish:

El filtro “wp_nav_menu_menu-slug_item” se ejecuta al final casi al final de wp_nav_menu, $items es un string que contiene la extructura de HTML del menu y $args son los argumentos que le pasaste a la funcion “wp_nav_menu”.

Lo unico que que tenes que fijarte o buscar para poder usar esto es cual es el “{MENU SLUG}” de tu menu.