I used a piece of code I found here in wordpress.stackexchange to add a custom link to my menu/nav. I adapted to my needs and it works great. The problem is it adds the link in the first position in my navigation list but I want it at the end after the other links.

Does anyone know how to make that happen?

function new_nav_menu_items($items, $args) {

 if( $args->theme_location == 'primary' ){
    $homelink = '<li><a  class="sites-button" data-toggle="animatedModal10">cool</a></li>';
    $items = $homelink . $items;
return $items;

add_filter( 'wp_nav_menu_items', 'new_nav_menu_items', 1, 2  );

1 Answer 1


Try changing this line:

$items = $homelink . $items;


$items = $items . $homelink;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.