I need to add the following:


To a specific menu link being generated by WordPress.

How can I achieve this?



This is not really a WordPress specific question, but since WordPress does not provide customization for menu items, I think you're gonna need this.

You can use .bind() in jQuery to add an event to user's click on an specific item. Take a look at this:

    jQuery( "#menu-item-57" ).bind( "click", function() {
        goog_report_conversion ('tel:800-123-4567');

Change the menu-item-57 to whatever ID of the menu item you want to bind a click event to.

  • 1
    Thank you, I was attempting something like this already, still getting to grips with certain WP things. Will post in correct overflow next time. Thanks again. – Grant Ab Jun 12 '17 at 10:24
  • @GrantAb You are most welcome. – Jack Johansson Jun 12 '17 at 10:27
  • This will certainly work, but has the drawback that it's generated on the user end, so it won't appear in the html source code. It that is important to you (for instance for SEO reasons) you should learn about the walker class, which will allow you to modify the native WP menus. A bit more here: wordpress.stackexchange.com/questions/169936/… – cjbj Jun 12 '17 at 12:19
  • @cjbj Thanks for your comments, I will look into the walker class. – Grant Ab Jun 12 '17 at 14:49

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.