arioch1984
12/12/2014 - 3:33 PM

add dynamic links to wordpress menu voice urls

add dynamic links to wordpress menu voice urls

<?php
add_filter( 'nav_menu_link_attributes', 'menu_override', 10, 3 );

function menu_override( $atts, $item, $args ) {
    $user = wp_get_current_user();
    $newlink = str_replace("--username--", $user->user_login, $atts[href]);
    $atts[href] = $newlink;
    return $atts;
}
?>