• Resolved erikshosting

    (@erikshosting)


    Hello,
    So i’ve been trying to add a _top or _parent target attribute to the links generated by the wordpress nav function.
    I’ve been looking in the codex at the argument $before_link and $before_text, but using these methods I can only get it to display
    <a href="example.com" class="exampleclass"><target="_top">Link Text</a>
    see how I can’t get into the <a> tag itself? I can only drop in before the link text or before the </a><a> tag itself..
    Any ideas?

    I know that you can enable the link target via the advanced target menu options, but the only options are ‘same window’ and ‘new window’, I would consider editing the core for a third option as this seems like a large omission, but I really hate modifying core files (especially because I have none edited so far)

    Like I said, Any ideas?

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter erikshosting

    (@erikshosting)

    Alright, I’ve dropped the links i want opened with _parent target into a specifically named div.

    Now i’ve added a jquery script to my header that should open all external links in the specific div in the _parent window.

    <script type="text/javascript" src="jquery.js"></script>
    <script type="text/javascript">
    $("#erocks-global-nav-div a[href^='https://']").attr("target","_parent");
    </script>

    So, the question is how do I modify this to just be all links external and internal. would I remove the https:// from between the ” marks?
    *EDIT:
    *This has some nasty effects. the iframe moves, then the _parent page moves. meaning two back button clicks to get back. and if you only hit it once, you get forwarded again..

    Thread Starter erikshosting

    (@erikshosting)

    *SOLVED*

    So, I put in a trac request to add _parent or _top top the advanced link target options in the menu editor (currently there is only _self, and _blank).

    But, I can’t wait while we debate if frames are “too 1995” to add the rest of the $args for ‘target options’, so I have built a custom walker..

    Hope this helps: My post outlining building a custom walker and adding _top or _parent target attributes

    I need this as well. I have a site that requires a frameset for one template (don’t ask). So I want to add _top to every menu link *except* the frameset page so the other links will exit the frameset.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘add target _top to wp_nav_menu link attributes’ is closed to new replies.