0

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

Try changing this line:

$items = $homelink . $items;

to

$items = $items . $homelink;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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