I appreciate the thought but offering any sort of compensation between forum members is not allowed by our guidelines. It tends to bring out bad actors. They are why civil people sometimes can’t do nice things for others.
The placement of the added link is governed by the first argument (what to search for) of the str_replace()
function. I used '</ul></div>'
, which occurs at the end of the menu’s HTML. The corresponding opening tags would be used to place the link in front. It has to be an exact match, so you’d include all the div tag’s attributes so the subsequent ul tag can be included.
The second argument is what replaces the first, so you’d need to include all of the first argument in the second to maintain the original HTML. I included the first at the end of the replacement. You’d instead include it at the start. There is a third argument, $menu
, don’t lose that one among all the other HTML you’d be changing ??
Instead of doing that, it should be possible to rearrange the order of menu elements with CSS alone. The CSS flex box model has an order:
property that can be used to alter the order elements appear in.