Injecting a javascript banner code right before & after wordpress navigation men (2 posts)

  1. z0haib
    Posted 2 years ago #

    I am trying to develop a plugin to inject a javascript banner code right before and after the wordpress navigation menu but I am unable to find any solution to this problem. Does anyone have any idea?

    I cannot append to a Div ID either since every wordpress theme uses different div id and class for navigation menu.


  2. bcworkz
    Posted 2 years ago #

    It's difficult to inject content from a plugin precisely because themes use different ways to display content, not just IDs and classes. For any theme that uses wp_nav_menu() to display navigation, use the 'wp_nav_menu' filter to place your own empty divs before and after the nav HTML. You can then use javascript to fill the divs with whatever. I would hope nearly all themes use this function, but there are no doubt a few mavericks that do not. Unless you want to develop custom code for each of these, they are pretty much a lost cause.

Topic Closed

This topic has been closed to new replies.

About this Topic