OpenCart 2.x. How to add custom link to categories menu

This article will show you how to add your custom link to categories menu.

You can check these guides on How to use Inspector tool on Mac and How to use Inspector tool on Windows.
  • First of all, open your site and inspect the menu link to see the structure of it.
    Usually, it looks like this:

You may have a slightly different layout with other classes or markup structure, nonetheless, it has to be reproduced to match the style rules applied to it.

  • Once you’re done with it, open the following file: catalog/view/theme/your_theme_name/template/common/header.tpl.
    You need to add the item twice to this file, once for mobiles and once for a desktop version of the site.
  • Locate the following block:
  • Paste your link keeping the structure before or after the <!–?php if ($categories) { echo $categories; } ?–> depending where you want to see a custom link, at the beginning or at the end of the menu.
    Eventually, it will look like this:
  • Now you will add items to your menu on the mobile view.
    Make the same changes to the desktop view, the block of the code is the following:

You may differ these blocks by the id assigned to them, the first one is menu-gadget, which is for mobiles and the second one is tm_menu – for desktops.