Reply To: Add Ajax Pro to my top menu

#11531
Ernest Marcinko
Ernest Marcinko
Keymaster

Hi!

There is no easy way unfortunately. WordPress does not allow placing any shortcodes as menu items, due to their structure and design I guess. It usually creates more issues, mostly regarding styling (vertical alignments, floating issues, placement problems, margin and padding issues, malfunctioning scripts etc..).

There is an experimental way of executing the search shortcodes in menus, but it needs an additional code, and it may not work as expected, or may not work at all. It’s worth a try though. Developers usually don’t make menus to be able to hold complex interactive elements, as it is already a highly interactive element, so please don’t expect too much of it.

1. Put this code into the functions.php file in your active theme directory:

This will try to detect if the menu title is a search shortcode. If so, it will be executed.

2. On the back-end menu editor, simply add a new custom menu item, with the search shortcode as it’s title: https://i.imgur.com/9b6P1sZ.png
3. Save the menu, and hope for the best.

On the default twenty sixteen theme it works perfectly: https://i.imgur.com/BKRHRVs.png
Then again, that theme is very well made and follows all rules regarding theme design and development, so it’s the best case scenario. I’ve seen some crazy menu solutions in very popular, best seller themes, so I highly doubt this will work as expected in every case.

Best,
Ernest Marcinko

If you like my products, don't forget to rate them on codecanyon :)