Dynamic URL in WordPress Navigation

admin

Administrator
Staff member
So I currently have Wordpress with some navigation links along these lines:

Link 1 | Link 2 | Link 3 etc.

Two things, first I'm trying to add a link inbetween Link 2 and Link 3. I am using this code, but it adds the link to the end of the unordered list. Is there a way to specify it's position?

Code:
    add_filter( 'wp_nav_menu_items', 'your_custom_menu_item', 10, 2 );
function your_custom_menu_item ( $items, $args ) {

        $items .= '<li><a href=#">Test Link</a></li>';
    return $items;
}

Secondly, I would like this new link to have a dynamic URL containing the users ID. I've tried looking up information regarding
Code:
get_currentuserinfo();
with wordpress, but I can't seem to find a way to include it in the function.