Hi there, I have created a secondary navigation
after_header
using a hook element inserting some of my object-nav.item-list-tabs individually like the code below, containing links for Recent Visitors, Search and Messages.It is working, but I’m not sure if this is the right way of doing it.
Could I instead insert a function like
bp_core_new_nav_item
(not working) from bp-core-buddybar.php instead of adding each link individually?Which is the right approach of doing that?
Regards
CarstenContent of the after_header hook element:
<div class="grid-container sub-navigation grid-parent"> <ul> <li id="visitors-personal-li"> <a href="https://domain/members/me/visitors/" id="user-visitors" class="menu-item menu-item-type-post_type menu-item-object-post messages-personal-li button" > Visits <span class="count"><?php echo visitors_get_unique_visitors_count( bp_loggedin_user_id() ); ?> </span> </a> </li> <a class="button" href="https://domain/search">Søg</a> <li id="messages-personal-li" > <a href="https://domain/members/me/messages/" id="user-messages" class="menu-item menu-item-type-post_type menu-item-object-post messages-personal-li button"> messages <span class="count"><?php echo bp_get_total_unread_messages_count( bp_loggedin_user_id() );?></span> </a> </li> </ul> </div>
Hi Carsten,
Thank you for the question.My suggestion will be to register a nav location(WordPress nav)
https://developer.wordpress.org/reference/functions/register_nav_menu/and then using BuddyPress nav items(You can enable it from screen options on the menu page).
That will save you any custom coding.
Regards
BrajeshHi Brajesh, thanks for the clarification, this function is new to me, I will check this out.
So I should not use the
bp_get_displayed_user_nav()
template tag?‘and then using BuddyPress nav items(You can enable it from screen options on the menu page).’
Which menu page are you referring to?
Regards
CarstenHi Carsten,
You are welcome.I am referring to WordPress admin menu management page.
The problem with bp_get_displayed_user_nav is it will only list correctly if you are on a user’s profile.
Regards
Brajesh
You must be logged in to reply to this topic.